Month names between 2 numeric Cymd format dates

510 pts.
Tags:
AS/400
RPGLE
hi,

Hi,

I have 2 Numeric field which has cymd date format

Date1     7s 0

Date2      7s 0

date1  = 1110128    ( which is 2011-01-28    : January)

date2 = 1120101  (which is 2012-01-01   ;January)

So what i need is , I need to write records in a file , what are all the  months inbetween these two dates like (February,March,April.................................December).

I have tried many logics, i couldnt get this. help me



Software/Hardware used:
As400

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 11  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • CharlieBrowne
    Are you asking how to select records from a file that has a date between these two dates? And you want to insert them into another file? Are you using RPG or SQL or something else? Is the date in this file in the same format?
    41,370 pointsBadges:
    report
  • philpl1jb
    Could you show us what you got and we'll help.
    49,720 pointsBadges:
    report
  • TomLiotta
    I need to write records in a file , what are all the months inbetween these two dates like (February,March,April.................................December). Does that mean that you would write 11 records to the file? What about these dates: date1 = 1100128 ( which is 2010-01-28 : January) date2 = 1120101 (which is 2012-01-01 ;January) Because they cover more than one year, it results in 23 months. Or these dates: date1 = 1120101 ( which is 2012-01-01 : January) date2 = 1120128 (which is 2012-01-28 ;January) Same year, same month. Do you need to write "January" to the file? In you original example, your list of months started with "February" even though the first date was in "January" (date1 = 1110128). So... Are there restrictions on the date values that you start and end with? Tom
    125,585 pointsBadges:
    report
  • 22917
    Yes I have two date fields which is Numeric 7s 0 (CYMD type- As i shown in my example). I need to write the month Gaps in a separate file which has only one field(here we have 11months inbetween thses two CYMD date formats) like We have January2011 and January2012, So i need to write in my file by leaving these two months/year as February2011,march2011,April2011,May2011.....November2011,December2011 How to write thses 11records in my file..
    510 pointsBadges:
    report
  • 22917
    What about these dates: date1 = 1100128 ( which is 2010-01-28 : January) date2 = 1120101 (which is 2012-01-01 ;January) Because they cover more than one year, it results in 23 months. Here Date1 is 1100128 but in my example I have given as 1110128( so 11month gap oly)
    510 pointsBadges:
    report
  • TomLiotta
    ...but in my example I have given as 1110128( so 11month gap oly) I understand your example. I want to know about the process beyond just the example. Without a description of the whole process, it sounds like an academic assignment or schoolwork or interview problems; and we can't do work on those. If that's what it is, we need to see the work that you have done first. Then we help to guide you past obstacles and into ways of solving the problem. If that's not what it is, then it should not be difficult for you to describe how we should handle the examples that I gave. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    So can you get the startYear, endYear, StartMonth, and EndMonth from the date? Phil
    49,720 pointsBadges:
    report
  • philpl1jb
    So I would see an outer loop from for curyear = startYear to endYear Inside would be a number of cases When startYear = endyear Loop from startMonth to endMonth DO stuff with MonthName( curMonth) When curYear = startYear loop from startMonth to 12 When curYear = endYear loop from 1 to endMonth Other loop from 1 to 12 end Year loop Something roughly along those lines
    49,720 pointsBadges:
    report
  • TomLiotta
    I have thoughts on ways to do it. How long should we wait before working on homework? Assignments become due eventually, so work starts to be less valuable to an OP. But useful solutions/methods can always be good to have on file for all of us. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Yes, this seems like it could be a homework question But the pattern of questions from this OP doesn't seem like those from a typical student. Providing some general logic doesn't seem too harmfu And sometimes I need a diversion. Phil “If I had followed my better judgment always, my life would have been a very dull one.” ― Edgar Rice Burroughs
    49,720 pointsBadges:
    report
  • TomLiotta
    the pattern of questions from this OP doesn’t seem like those from a typical student. I disagree. The pattern seems directly that of a student. However, this seems to be a student for personal motivation rather than enrolled in a course. That makes me feel more interested in helping. Providing some general logic doesn’t seem too harmful... I agree. I was wondering more in a general context. An assignment due on "Monday" won't be helped much by a discussion on Wednesday. Answers could be useful to students in later enrollments, but assignments should be changed and updated anyway. If answers are available, course updates are almost forced. We might see fewer 'assignments' requiring RPG II and III. Courses should move into the current century. For this particular OP, a difficulty has been in keeping a conversation going. Time zones and even days of the week interfere. I'd guess that language doesn't help. Iit's harder to get the idea across that help can be given to students, just not answers. Two-way conversation is important for help Now, for the problem itself, there are multiple possibilities. The best will probably depend on specific requirements such as whether or not dates are guaranteed to be less than a year apart. (And we know how likely "guarantee" is.) Consider a 24-element array containing month names January through December twice. Pull the month number from the first date and the duration in months from the two dates. With those two values and the array, you can just zip through the names. (Technically, there should only need to be 23 names since there'd never be a need for the final "December".) The logic would be trivial. It's just like positioning along a 'number line' and ticking of the integer points. But the problem itself is a little unlikely, so the particular logic gets meaningless. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following