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

Difference between two dates


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Thu May 29, 2008 7:51 pm
Reply with quote

Hi,
How to find the difference between two dates throug SORT.
My input is like this: 20080501 20080520

Can we get 3 months bfore date of a particular date?

Eq: input: 20080101
Output:20071001


Regards,
Bipin Peter
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 29, 2008 9:36 pm
Reply with quote

bipinpeter,

DFSORT does not have any built-in functions for doing arithmetic on date fields. If your dates are both in the same year then it is very easy to calculate the difference.
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 02, 2010 4:21 am
Reply with quote

bipinpeter wrote:
Hi,
How to find the difference between two dates throug SORT.
My input is like this: 20080501 20080520


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 be used to calculate the number of days difference between two dates. The result is an 8-byte value consisting of a sign and 7 digits (sddddddd). If the first date is greater than or equal to the second date, the sign is + (plus). If the first date is less than the second date, the sign is - (minus).


Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
----+----1----+----2----+----3----+----4----+----5----+--
20080501 20080520                                       
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INREC OVERLAY=(20:10,8,Y4T,DATEDIFF,1,8,Y4T)           
//*


The output from the above job is

Code:

20080501 20080520  +0000019   


bipinpeter wrote:

Can we get 3 months bfore date of a particular date?

Eq: input: 20080101
Output:20071001


Regards,
Bipin Peter



DFSORT now also supports adding/subtracting days/months/years from a date very easily like shown below

Code:

//STEP0200 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
----+----1----+----2----+----3----+----4----+----5----+-
20080101                                               
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INREC OVERLAY=(10:1,8,Y4T,SUBMONS,+3,TOGREG=Y4T)     
//*


The output from this job is

Code:

20080101 20071001




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

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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Amount of days between two dates PL/I & Assembler 8
No new posts What is the difference between Taskty... Compuware & Other Tools 2
No new posts Difference between VALIDPROC and CHEC... DB2 3
Search our Forums:

Back to Top