Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: How to Add and increment the date in MM/DD/YYYY format
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

Site Director


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

PostPosted: Thu Mar 08, 2007 9:00 am    Post subject:
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    Post subject:
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    Post subject: Reply to: How to Add and increment the date in MM/DD/YYYY fo
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:

http://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    Post subject:
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:

http://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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm
No new posts Overlay the system date Danielle.Filteau SYNCSORT 4 Fri Mar 03, 2017 1:16 am
No new posts Checking Current date vickey_dw DFSORT/ICETOOL 1 Wed Feb 08, 2017 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us