Adding month to a date



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Adding month to a date

Postby Puffe » Mon Mar 26, 2012 1:25 pm

Hi,

I have an input file that consists of several records and I'm only interested in one of them.
So I use command
INCLUDE COND=(1,4,CH,EQ,C'1234')
to extract that record.

In position 5-12 there is a date in format (yyyymmdd) that differs from time to time.
So I want to add one month to that date-value and I want the day to be the first weekday of the new month, so it shouldn't be a saturday or sunday.
Let say that the date is 20120326 so the result I want in my output file should be:
FLD1,'20120402'

I think this can be done by using DFSORT.

Regards,

Mike
Puffe
 
Posts: 21
Joined: Mon May 02, 2011 1:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding month to a date

Postby skolusu » Mon Mar 26, 2012 9:27 pm

Puffe wrote:In position 5-12 there is a date in format (yyyymmdd) that differs from time to time.
So I want to add one month to that date-value and I want the day to be the first weekday of the new month, so it shouldn't be a saturday or sunday.
Let say that the date is 20120326 so the result I want in my output file should be:
FLD1,'20120402'

I think this can be done by using DFSORT.

Regards,

Mike



Mike,

Your description is confusing. I guess you just need to get the first weekday of the next month. Assuming your input is RECFM=FB and LRECL=80, the following DFSORT JCL will give you the desired results.

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
123420120326                                           
123420120430                                           
123420120530                                           
123420120630                                           
123420120731                                           
123420120831                                           
123420120928                                           
123420121031                                           
123420121130                                           
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  OPTION COPY                                           
  INCLUDE COND=(1,4,CH,EQ,C'1234')                     
                                                       
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,                 
  OVERLAY=(81:05,8,Y4T,ADDMONS,+1,TOGREG=Y4T,87:C'01', 
              81,8,Y4T,WEEKDAY=CHAR3)),                 
                                                       
  IFTHEN=(WHEN=(89,3,CH,EQ,C'SAT'),                     
  OVERLAY=(5:81,8,Y4T,ADDDAYS,+2,TOGREG=Y4T)),         
                                                       
  IFTHEN=(WHEN=(89,3,CH,EQ,C'SUN'),                     
  OVERLAY=(5:81,8,Y4T,ADDDAYS,+1,TOGREG=Y4T)),         
                                                       
  IFTHEN=(WHEN=NONE,OVERLAY=(5:81,8))                   
//*


The output from the above job would be

123420120402
123420120501
123420120601
123420120702
123420120801
123420120903
123420121001
123420121101
123420121203
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post