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

Number of years the records is present in the file.


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

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Thu Oct 16, 2008 3:32 pm
Reply with quote

Hi all,
I have a requirement in which i have to find the number of years the records are present in the file(from current date). Each record will have a date in the first 10 bytes (mm/dd/yyyy).This date corresponds to when the record was written in the file.The date might vary for each record. I need to find how many years each record is present in the file.

Input file details:
Length : 50 bytes (10 bytes date + 40 bytes data)

Sample record:
10/12/2005.....40 bytes data....

Expected output:
Length: 58 bytes (50 bytes data + 08 bytes date (difference date)) I have to use system date to find the difference date.
difference date format -- yyyymmdd.
Sample o/p record:
50 bytes i/p record..00071002
here '0007' corresponds to number of years the record was present in file.
'10' corresponds to number of months and '02' corresponds to number of days.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Oct 16, 2008 9:45 pm
Reply with quote

passion_sujesh,

Sort products do not have the ability to calculate the difference between 2 dates as requested by you
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:27 am
Reply with quote

passion_sujesh,

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----+----6---
10/12/2005.....40 BYTES DATA....                               
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  INREC IFOUTLEN=58,                                           
  IFTHEN=(WHEN=INIT,BUILD=(1,50,DATE1,1,10,UFF,M11,LENGTH=8)),
  IFTHEN=(WHEN=INIT,OVERLAY=(51:51,8,Y4T,DATEDIFF,59,8,Y4W))   
//*


The output from the above job is

Code:

10/12/2005.....40 BYTES DATA....                  +0001846


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 How to split large record length file... DFSORT/ICETOOL 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top