Re: Using SORT to generate sequential Dates
Hi Kolusu, and thanks for your help. I have been out for a few days, and got to work with it today. It is just what I need, and is easy enough to change the volume of data to add another month (which I was going to try later). I appreciate all that you do, and for your expert knowledge! Thank you and best regards, Billy Ashton -- Original Message -- From "Sri h Kolusu" To IBM-MAIN@listserv.ua.edu Date 6/30/2022 6:14:04 PM Subject Re: Using SORT to generate sequential Dates Billy, If I understand your requirement correctly, you need current month begin to end and 1 or 2 months before the current month. So if you are run the job today(June 30th), it will generate the dates from April 1st to June 30th. If you run the job on July 1st then it would generate dates beginning May 1 thru May 31 , June 1 thru June 30 and July 1 thru July 31. If that is true, then use the following job which will give you the desired results. //*** //* Generate DFSORT symbols for begin date and repeat value * //* Begindate = Current month - 2 months (CCYYMM) 01 * //* Enddate= Last day of the current month (CCYYMMDD) * //* Repeatval = Number of entries (Enddate - Begmmdd) * //*** //STEP0100 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD * ABC //SORTOUT DD DSN=&,DISP=(,PASS),SPACE=(TRK,(1,0)) //SYSINDD * OPTION COPY,STOPAFT=1,NULLOUT=RC4 INREC OVERLAY=(01:DATE2-2,C'01', 11:DATE1, 21:11,08,Y4T,LASTDAYM,TOGREG=Y4T, 31:21,08,Y4T,DATEDIFF,01,08,Y4T) OUTFIL BUILD=(C'SDATE,C''',01,08,C,/, C'EDATE,C''',21,08,C,/, C'RPVAL,',31,08,UFF,ADD,+1,M11,LENGTH=8, 80:X) /* //*** //* Use the symbols from previous step and generate the data* //*** //STEP0200 EXEC PGM=SORT,COND=(0,LT) //SYSOUT DD SYSOUT=* //SYMNOUT DD SYSOUT=* //SYMNAMES DD DISP=(OLD,PASS),DSN=& //SORTIN DD * ABC //SORTOUT DD SYSOUT=* //SYSINDD * OPTION COPY,STOPAFT=1,NULLOUT=RC4 OUTFIL REPEAT=RPVAL, IFOUTLEN=80, IFTHEN=(WHEN=INIT, OVERLAY=(081:SDATE, 091:SEQNUM,3,ZD,START=0, 101:081,08,Y4T,ADDDAYS,091,3,ZD,TOGREG=Y4T)), IFTHEN=(WHEN=INIT, BUILD=(C'(''',C'D',SEQNUM,3,ZD,C''',', C,101,04,C'-',105,02,C'-',107,02,C''',', C,101,08,C''',', 101,08,C',', C,101,02,C''',', C,103,02,C''',', C,105,02,C''',', C,107,02,C''')')) /* Thanks, Sri Hari Kolusu DFSORT Development IBM Corporation -Original Message- From: IBM Mainframe Discussion List On Behalf Of Billy Ashton Sent: Thursday, June 30, 2022 2:30 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: [EXTERNAL] Re: Using SORT to generate sequential Dates Kolusu, the key data is that I have the previous month start and end date (for today, it would be May 1 and 31), with some range of dates before that. I also need at least the end of the current month (June 30, today). For running it tomorrow, I need at least June 1 - 30 (with some dates in May) and July 1 to 31. Having more dates than this is fine, and is no problem to go back even another month and ahead even another month. Billy Sri h Kolusu wrote: I need this for about 3 months worth of dates. . The dates should start either on the 15th of the month, 2 months ago, or 45 days ago (whichever is easier) Billy, It is easy to generate the dates in the required format, however a few clarifications needed. • Can the dates start from current date and go back to 3 months of dates? • Do you want the ability of passing ANY VALID date and number of entries needed? • 3 months dates can result in 88 - 93 entries depending on the current date. For example today's Current-date is 2022-06-30 and subtracting 3 months from it results in 2022-03-30. So we can have the start date from March 30th and get to Current date which will be 93 days of data. Is that OK? If we always use 93 as number of entries to generate then it might exceed the current date. I can handle it dynamically have the repeat value. Is that needed ? or is it ok to have 93 entries of data? Thanks, Kolusu DFSORT Development IBM Corporation -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu<mailto:lists...@listserv.ua.edu> with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu<mailto:lists...@listserv.ua.edu> wi
Re: Using SORT to generate sequential Dates
>> I would also like for the date of Easter, day of the week Christmas falls >> on, the moon phase, and the Chinese zodiac year to be appended. Steve, Your wish is granted for Easter day https://www.mvsforums.com/helpboards/viewtopic.php?p=63383#63383 Thanks, Kolusu DFSORT Development IBM Corporation -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
Hi, You said: "... lunar calendar used in Israel ..." The lunar calendar is used by all Jews, not just Jews in Israel. That is why Passover, Chanukah, Rosh HaShanah etc. don't always start on the same solar date. Regards, David On 2022-06-30 19:35, Retired Mainframer wrote: -Original Message- From: IBM Mainframe Discussion List On Behalf Of Paul Gilmartin Sent: Thursday, June 30, 2022 3:29 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Using SORT to generate sequential Dates On Thu, 30 Jun 2022 22:22:08 +, Sri h Kolusu wrote: I tried this in Rexx. I found it astonishingly hard to get "the end of the current month". DFSORT has plethora of date related functions that can get the last day of month, Quarter and year quite easily in either Gregorian format or Julian format. So it accounts for thee switch from Julian to Gregorian in Catholic countries in 1582 and in Protestant countries in 1752? -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
I would also like for the date of Easter, day of the week Christmas falls on, the moon phase, and the Chinese zodiac year to be appended. Otherwise, DFSORT is so lame. sas On Thu, Jun 30, 2022 at 7:36 PM Retired Mainframer < 03a485c129c3-dmarc-requ...@listserv.ua.edu> wrote: > -Original Message- > From: IBM Mainframe Discussion List On Behalf > Of > Paul Gilmartin > Sent: Thursday, June 30, 2022 3:29 PM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: Using SORT to generate sequential Dates > > On Thu, 30 Jun 2022 22:22:08 +, Sri h Kolusu > wrote: > > >>>I tried this in Rexx. I found it astonishingly hard to get "the end of > the > >>>current month". > > > >DFSORT has plethora of date related functions that can get the last day > of > >month, Quarter and year quite easily in either Gregorian format or Julian > >format. > > > So it accounts for thee switch from Julian to Gregorian in Catholic > countries > in 1582 > and in Protestant countries in 1752? > > -- > gil > > How come you didn't ask about the lunar calendar used in Israel or the one > used in Muslim countries? > > -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
On 1/07/2022 8:13 am, Paul Gilmartin wrote: I tried this in Rexx. I found it astonishingly hard to get "the end of the current month". Would DFSORT do betteer? I tried it in Java: import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class DateList { public static void main(String[] args) { LocalDate today = LocalDate.now(); LocalDate monthStart = LocalDate.of(today.getYear(), today.getMonth(), 1); LocalDate startDate = monthStart.minusMonths(2).plusDays(14); LocalDate endDate = monthStart.plusMonths(1); int count = 1; for (LocalDate date = startDate; date.isBefore(endDate); date = date.plusDays(1)) { System.out.format("('D%03d','%s','%s',%s,'%02d','%02d','%02d','%02d')%n", count, DateTimeFormatter.ISO_LOCAL_DATE.format(date), DateTimeFormatter.BASIC_ISO_DATE.format(date), DateTimeFormatter.BASIC_ISO_DATE.format(date), date.getYear() / 100, date.getYear() % 100, date.getMonthValue(), date.getDayOfMonth()); count++; } } } -- Andrew Rowley Black Hill Software -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
-Original Message- From: IBM Mainframe Discussion List On Behalf Of Paul Gilmartin Sent: Thursday, June 30, 2022 3:29 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Using SORT to generate sequential Dates On Thu, 30 Jun 2022 22:22:08 +, Sri h Kolusu wrote: >>>I tried this in Rexx. I found it astonishingly hard to get "the end of the >>>current month". > >DFSORT has plethora of date related functions that can get the last day of >month, Quarter and year quite easily in either Gregorian format or Julian >format. > So it accounts for thee switch from Julian to Gregorian in Catholic countries in 1582 and in Protestant countries in 1752? -- gil How come you didn't ask about the lunar calendar used in Israel or the one used in Muslim countries? -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
>> So it accounts for thee switch from Julian to Gregorian in Catholic >> countries in 1582 and in Protestant countries in 1752? Not really. For older years. it just follows the general rules of Leap year and it is not specific to any country. Thanks, Kolusu -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
If your data goes back that far. Charles -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Paul Gilmartin Sent: Thursday, June 30, 2022 3:29 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Using SORT to generate sequential Dates On Thu, 30 Jun 2022 22:22:08 +, Sri h Kolusu wrote: >>>I tried this in Rexx. I found it astonishingly hard to get "the end of the >>>current month". > >DFSORT has plethora of date related functions that can get the last day of >month, Quarter and year quite easily in either Gregorian format or Julian >format. > So it accounts for thee switch from Julian to Gregorian in Catholic countries in 1582 and in Protestant countries in 1752? -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
On Thu, 30 Jun 2022 22:22:08 +, Sri h Kolusu wrote: >>>I tried this in Rexx. I found it astonishingly hard to get "the end of the >>>current month". > >DFSORT has plethora of date related functions that can get the last day of >month, Quarter and year quite easily in either Gregorian format or Julian >format. > So it accounts for thee switch from Julian to Gregorian in Catholic countries in 1582 and in Protestant countries in 1752? -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
On Thu, 30 Jun 2022 17:29:31 -0400, Billy Ashton wrote: >... >Having more dates than this is fine, and is no problem to go back even >another month and ahead even another month. > So would current date - 61 days through current date + 30 days be acceptable in all cases? -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
>>I tried this in Rexx. I found it astonishingly hard to get "the end of the >>current month". DFSORT has plethora of date related functions that can get the last day of month, Quarter and year quite easily in either Gregorian format or Julian format. //STEP0100 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD * ABC //SORTOUT DD SYSOUT=* //SYSINDD * OPTION COPY INREC OVERLAY=(DATE1, # current date X, # Space 01,08,Y4T,LASTDAYM,TOGREG=Y4T, # Lastday of month X, # Space 01,08,Y4T,LASTDAYQ,TOGREG=Y4T, # Lastday of Qaurter X, # Space 01,08,Y4T,LASTDAYY,TOGREG=Y4T) # Lastday of year /* Output 20220630 20220630 20220630 20221231 /* Not tested for December, January, or February. */ DFSORT does the date validation considering leap years and can process the date from 0001-01-01 thru -12-31 Thanks, Kolusu -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
Billy, If I understand your requirement correctly, you need current month begin to end and 1 or 2 months before the current month. So if you are run the job today(June 30th), it will generate the dates from April 1st to June 30th. If you run the job on July 1st then it would generate dates beginning May 1 thru May 31 , June 1 thru June 30 and July 1 thru July 31. If that is true, then use the following job which will give you the desired results. //*** //* Generate DFSORT symbols for begin date and repeat value * //* Begindate = Current month - 2 months (CCYYMM) 01 * //* Enddate= Last day of the current month (CCYYMMDD) * //* Repeatval = Number of entries (Enddate - Begmmdd) * //*** //STEP0100 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD * ABC //SORTOUT DD DSN=&,DISP=(,PASS),SPACE=(TRK,(1,0)) //SYSINDD * OPTION COPY,STOPAFT=1,NULLOUT=RC4 INREC OVERLAY=(01:DATE2-2,C'01', 11:DATE1, 21:11,08,Y4T,LASTDAYM,TOGREG=Y4T, 31:21,08,Y4T,DATEDIFF,01,08,Y4T) OUTFIL BUILD=(C'SDATE,C''',01,08,C,/, C'EDATE,C''',21,08,C,/, C'RPVAL,',31,08,UFF,ADD,+1,M11,LENGTH=8, 80:X) /* //*** //* Use the symbols from previous step and generate the data* //*** //STEP0200 EXEC PGM=SORT,COND=(0,LT) //SYSOUT DD SYSOUT=* //SYMNOUT DD SYSOUT=* //SYMNAMES DD DISP=(OLD,PASS),DSN=& //SORTIN DD * ABC //SORTOUT DD SYSOUT=* //SYSINDD * OPTION COPY,STOPAFT=1,NULLOUT=RC4 OUTFIL REPEAT=RPVAL, IFOUTLEN=80, IFTHEN=(WHEN=INIT, OVERLAY=(081:SDATE, 091:SEQNUM,3,ZD,START=0, 101:081,08,Y4T,ADDDAYS,091,3,ZD,TOGREG=Y4T)), IFTHEN=(WHEN=INIT, BUILD=(C'(''',C'D',SEQNUM,3,ZD,C''',', C,101,04,C'-',105,02,C'-',107,02,C''',', C,101,08,C''',', 101,08,C',', C,101,02,C''',', C,103,02,C''',', C,105,02,C''',', C,107,02,C''')')) /* Thanks, Sri Hari Kolusu DFSORT Development IBM Corporation -Original Message- From: IBM Mainframe Discussion List On Behalf Of Billy Ashton Sent: Thursday, June 30, 2022 2:30 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: [EXTERNAL] Re: Using SORT to generate sequential Dates Kolusu, the key data is that I have the previous month start and end date (for today, it would be May 1 and 31), with some range of dates before that. I also need at least the end of the current month (June 30, today). For running it tomorrow, I need at least June 1 - 30 (with some dates in May) and July 1 to 31. Having more dates than this is fine, and is no problem to go back even another month and ahead even another month. Billy Sri h Kolusu wrote: > >> >>> >>> I need this for about 3 months worth of dates. . The dates should >>> start either on the 15th of the month, 2 months ago, or 45 days ago >>> (whichever is easier) >> > > > Billy, > > It is easy to generate the dates in the required format, however a > few clarifications needed. > • Can the dates start from current date and go back to 3 months > of dates? > • Do you want the ability of passing ANY VALID date and number > of entries needed? > • 3 months dates can result in 88 - 93 entries depending on the > current date. For example today's Current-date is 2022-06-30 and > subtracting 3 months from it results in 2022-03-30. So we can have the > start date from March 30th and get to Current date which will be 93 > days of data. Is that OK? If we always use 93 as number of entries to > generate then it might exceed the current date. I can handle it > dynamically have the repeat value. Is that needed ? or is it ok to > have 93 entries of data? > > > Thanks, > Kolusu > DFSORT Development > IBM Corporation > > > > -- > For IBM-MAIN subscribe / signoff / archive access instructions, send > email to lists...@listserv.ua.edu<mailto:lists...@listserv.ua.edu> with the > message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu<mailto:lists...@listserv.ua.edu> with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
On Thu, 30 Jun 2022 20:23:16 +, Billy Ashton wrote: >... >I would like to use SORT to generate a file ... > >I need this for about 3 months worth of dates. The dates should start >either on the 15th of the month, 2 months ago, or 45 days ago (whichever >is easier) and go up through the end of the current month (it could even >start on the 1st day of 2 months ago if necessary). So for today (June >30), it would have >('D001','2022-04-15','20220415',20220415,'20','22','04','15') > I tried this in Rexx. I found it astonishingly hard to get "the end of the current month". Would DFSORT do betteer? Anyway, with no attention to formatting: trace N signal on novalue Bas = date( 'Base' ) Std = date( 'Standard', Bas, 'Base' ) parse var Std YM 7 . MBeg = date( 'Base', YM'01', 'Standard' ) /* Beginning of this month */ Nextm = date( 'Standard', MBeg + 45, 'Base' ) /* Middle of next month */ parse var Nextm Nextm 7 . Nextm = date( 'Base', Nextm'01', 'Standard' ) /* First of next month */ Offset = Bas - 46 Do = Bas - 45 to Nextm - 1 say - Offset date( 'Standard', , 'Base' ) end /* Not tested for December, January, or February. */ -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
Kolusu, the key data is that I have the previous month start and end date (for today, it would be May 1 and 31), with some range of dates before that. I also need at least the end of the current month (June 30, today). For running it tomorrow, I need at least June 1 - 30 (with some dates in May) and July 1 to 31. Having more dates than this is fine, and is no problem to go back even another month and ahead even another month. Billy Sri h Kolusu wrote: I need this for about 3 months worth of dates. . The dates should start either on the 15th of the month, 2 months ago, or 45 days ago (whichever is easier) Billy, It is easy to generate the dates in the required format, however a few clarifications needed. • Can the dates start from current date and go back to 3 months of dates? • Do you want the ability of passing ANY VALID date and number of entries needed? • 3 months dates can result in 88 - 93 entries depending on the current date. For example today's Current-date is 2022-06-30 and subtracting 3 months from it results in 2022-03-30. So we can have the start date from March 30th and get to Current date which will be 93 days of data. Is that OK? If we always use 93 as number of entries to generate then it might exceed the current date. I can handle it dynamically have the repeat value. Is that needed ? or is it ok to have 93 entries of data? Thanks, Kolusu DFSORT Development IBM Corporation -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Using SORT to generate sequential Dates
>> I need this for about 3 months worth of dates. . The dates should start >> either on the 15th of the month, 2 months ago, or 45 days ago (whichever is >> easier) Billy, It is easy to generate the dates in the required format, however a few clarifications needed. • Can the dates start from current date and go back to 3 months of dates? • Do you want the ability of passing ANY VALID date and number of entries needed? • 3 months dates can result in 88 - 93 entries depending on the current date. For example today's Current-date is 2022-06-30 and subtracting 3 months from it results in 2022-03-30. So we can have the start date from March 30th and get to Current date which will be 93 days of data. Is that OK? If we always use 93 as number of entries to generate then it might exceed the current date. I can handle it dynamically have the repeat value. Is that needed ? or is it ok to have 93 entries of data? Thanks, Kolusu DFSORT Development IBM Corporation -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Using SORT to generate sequential Dates
Hello all! I have a new SORT challenge... I have looked up and found out how to use SORT to get the current date and output it, but I need to go further, and could not find this. I would like to use SORT to generate a file like this that I am using for testing some SQL logic I am working on: ('D001','ccyy-mm-dd','ccyymmdd',ccyymmdd,'cc','yy','mm','dd') I need this for about 3 months worth of dates. The dates should start either on the 15th of the month, 2 months ago, or 45 days ago (whichever is easier) and go up through the end of the current month (it could even start on the 1st day of 2 months ago if necessary). So for today (June 30), it would have ('D001','2022-04-15','20220415',20220415,'20','22','04','15') ('D002','2022-04-16','20220416',20220416,'20','22','04','16') . . . ('D077','2022-06-30','20220630',20220630,'20','22','06','30') I can generate the sequential number, but have trouble with incremental dates or getting the start date. Can Kolusu or someone else help with this? I am sure it is simple with a repeat, but I can't come up with anything. Thank you and best regards, Billy Ashton -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN