View previous topic :: View next topic
Author
Message
Michael Angelo Pagala New User Joined: 02 Mar 2007Posts: 34 Location: somewhere in the middle
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
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
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
Alan Voss New User Joined: 29 Nov 2006Posts: 32 Location: Jacksonville, FL
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
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
Please enable JavaScript!