MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Date Logic

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
SK2007
Beginner


Joined: 25 Jan 2007
Posts: 40
Topics: 17

PostPosted: Thu Feb 07, 2008 11:15 am    Post subject: Date Logic Reply with quote

Hi,

Please help me in the following requirement.
The requirement is take system date, and add 6 days to that date.
If it rolls over to next month, then add 2 to the system month otherwise add 1 to the system month. I need this to be done in SORT

For ex:
If the system run date is 12/25/2007.
The out put date would be : 01/25/2008. Because the date is 12/31/2007 after adding 6 days.

If the system run date is 12/26/2007.
The out put date would be : 02/25/2008. Because the date rolls over to next month.


Thanks for your kelp as always.
SK2007.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Feb 07, 2008 1:35 pm    Post subject: Reply with quote

Quote:
If the system run date is 12/26/2007.
The out put date would be : 02/25/2008. Because the date rolls over to next month.


Shouldn't the output date be 02/26/2008? Why would the day change from 26 to 25?

Here's a DFSORT job that I think will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN                                 
//SYSOUT    DD  SYSOUT=*                                 
//SORTIN DD *                                           
RECORD                                                   
/*
//SORTOUT DD SYSOUT=*                                   
//SYSIN    DD    *                                       
  OPTION COPY                                           
  INREC IFOUTLEN=10,                                     
    IFTHEN=(WHEN=INIT,BUILD=(DATE1(/),DATE1,DATE1+6)),   
    IFTHEN=(WHEN=INIT,BUILD=(6,5,C'/',1,4,11,16)),       
    IFTHEN=(WHEN=(15,2,ZD,EQ,23,2,ZD),                   
      OVERLAY=(1,2,ZD,ADD,+1,EDIT=(TT)),HIT=NEXT),       
    IFTHEN=(WHEN=(15,2,ZD,NE,23,2,ZD),                   
      OVERLAY=(1,2,ZD,ADD,+2,EDIT=(TT)),HIT=NEXT),       
    IFTHEN=(WHEN=(1,2,ZD,EQ,+13),                       
      OVERLAY=(C'01',7:7,4,ZD,ADD,+1,EDIT=(TTTT))),     
    IFTHEN=(WHEN=(1,2,ZD,EQ,+14),                       
      OVERLAY=(C'02',7:7,4,ZD,ADD,+1,EDIT=(TTTT)))       
/*


For today's date (02/07/2008), SORTOUT would have:

03/07/2008

For 12/25/2007, SORTOUT would have

01/25/2008

For 12/26/2007, SORTOUT would have

02/26/2008
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SK2007
Beginner


Joined: 25 Jan 2007
Posts: 40
Topics: 17

PostPosted: Thu Feb 07, 2008 2:20 pm    Post subject: Reply with quote

Thanks Frank,

Yes, it should be 02/26/2008. Thanks for your help.
I also tried with the follwoing code and got the result. Please let me know if you see any problem.

Code:

//S1       EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
JUST A DUMMY RECORD                                       
/*                                                       
//SORTOUT  DD SYSOUT=*                                   
//SORTWK01 DD UNIT=WRKDA,SPACE=(CYL,(400,100))           
//SYSIN    DD *                                           
 INREC FIELDS=(DATE1(/)+6)                               
 SORT FIELDS=COPY                                         
 OUTREC FIELDS=(1,4,                                     
                C'/',                                     
                6,2,ZD,ADD,+1,EDIT=(TT),                 
                C'/',                                     
                9,2,                                     
                6,2,CHANGE=(1,C'13',C'1'),NOMATCH=(C'0'))
 OUTFIL FNAMES=SORTOUT,                                   
        OUTREC=(1,4,ZD,ADD,11,1,ZD,EDIT=(TTTT),           
                C'/',                                     
                6,2,CHANGE=(2,C'13',C'01'),NOMATCH=(6,2),
                C'/',                                     
                9,2)   
/*                     
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Feb 07, 2008 3:30 pm    Post subject: Reply with quote

Your job doesn't appear to give you the output you said you wanted. For example, for 12/25/2007 you said you wanted 01/25/2008. That's what my job gives you. But it appears your job gives you 2007/01/31.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Feb 07, 2008 3:57 pm    Post subject: Reply with quote

SK2007,

Also be aware of getting an invalid date if it is a leap year. For ex : if you are running the job on Jan 24 of 2008 and you add 6 days to it , it is Jan 30th and now you add 1 month to it which makes it feb 30th 2008 which is an invalid date.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SK2007
Beginner


Joined: 25 Jan 2007
Posts: 40
Topics: 17

PostPosted: Fri Feb 08, 2008 8:01 am    Post subject: Reply with quote

Thanks Frank and Kolusu for your suggestions and observations.

SK2007.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Oct 25, 2010 5:25 pm    Post subject: Reply with quote

SK2007,

With PTF UK90025 for z/OS DFSORT V1R10 and PTF UK90026 for z/OS DFSORT V1R12(Oct, 2010), DFSORT now supports date arithmetic which can add/subtract days, months or years to a given date like shown below.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
DUMMY RECORD                                                     
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,BUILD=(DATE1)),                         
  IFTHEN=(WHEN=INIT,OVERLAY=(10:1,8,Y4T,ADDDAYS,+6,TOGREG=Y4T)), 
  IFTHEN=(WHEN=(5,2,CH,EQ,14,2,CH),                               
  BUILD=(1,8,Y4T,ADDMONS,+1,TOGREG=Y4W(/))),                     
  IFTHEN=(WHEN=NONE,                                             
  BUILD=(1,8,Y4T,ADDMONS,+2,TOGREG=Y4W(/)))                       
//*



For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group