IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Add and increment the date in MM/DD/YYYY format


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Michael Angelo Pagala

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Wed Mar 07, 2007 3:47 pm
Reply with quote

Hi!

Can you please help me or teach me how to add/increment a date.

The date is in MM/DD/YYYY format

Sample input
02/27/2007

then I will add any number of days so for this I will add 10 days..

The output must be
03/10/2007

It can be in sort/SAS/Easytrieve

Thanks a lot!
this is my first time to post here so please be kind to me icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 08, 2007 9:00 am
Reply with quote

Hello,

Where is the date (field?) stored?

Is this a control date or do you want to change the date across a file?

Please post what you have and what you would like for a result.
Back to top
View user's profile Send private message
Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Fri Mar 09, 2007 3:12 am
Reply with quote

I think you want to add 11 days to get 03/10/2007,

Anyway the SAS solution (two different ways) is:
data indates;
input indate mmddyy10.;
format indate mmddyy10.;
cards;
02/27/2007;
data outdates;
set indates;
increment = 10;
outdate_a = indate+increment;
outdate_b = intnx("DAY",indate,increment);
format outdate_a outdate_b mmddyy10.;
put indate increment outdate_a outdate_b ;
run;

Yielding:
02/27/2007 10 03/09/2007 03/09/2007
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Nov 17, 2009 3:58 am
Reply with quote

Michael Angelo Pagala,

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the new date conversion function TOGREG/TOJUL like shown below to get the desired results
Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
02/27/2007                                                       
02/28/2008                                                       
12/29/2008                                                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                               
  INREC IFOUTLEN=80,                                             
  IFTHEN=(WHEN=INIT,OVERLAY=(81:1,10,UFF,M11,LENGTH=8)),         
  IFTHEN=(WHEN=INIT,OVERLAY=(89:81,8,Y4W,TOJUL=Y4W)),             
  IFTHEN=(WHEN=INIT,OVERLAY=(89:+10,ADD,89,3,ZD,EDIT=(TTT))),     
  IFTHEN=(WHEN=INIT,OVERLAY=(96:89,7,Y4W,TOJUL=Y4W)),             
  IFTHEN=(WHEN=(96,1,CH,EQ,C'*'),OVERLAY=(103:85,4,C'1231',       
  103,8,Y4T,TOJUL=Y4W,89:89,3,ZD,SUB,111,3,ZD,EDIT=(TTT),         
  +1,ADD,92,4,ZD,EDIT=(TTTT),96:89,7,Y4W,TOJUL=Y4W),HIT=NEXT),   
  IFTHEN=(WHEN=(96,7,ZD,GT,0),OVERLAY=(1:96,7,Y4W,TOGREG=Y4W(/)))
//*


The output is (FEB 27 2007 + 10 Days = March 9th 2007 and not march 10 as you show

Code:

03/09/2007
03/09/2008
01/08/2009


For complete details on date conversion functions and the other new functions available with the Nov, 2009 DFSORT PTF, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Oct 30, 2010 1:07 am
Reply with quote

Michael Angelo Pagala,

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct, 2010), adding number of days is much easier like shown below

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
----+----1----+----2----+----3----+----4----+----5----+----6-
02/27/2007
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFOUTLEN=80,                                                 
  IFTHEN=(WHEN=INIT,OVERLAY=(81:1,10,UFF,M11,LENGTH=8)),             
  IFTHEN=(WHEN=INIT,OVERLAY=(01:81,8,Y4W,ADDDAYS,+10,TOGREG=Y4W(/)))
//*


The output from this job is
Code:

03/09/2007



For complete details on the new DFSORT and ICETOOL functions available with the Oct, 2010 PTF, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top