Posted: Sun Nov 22, 2009 5:44 pm Post subject: Subtracting days from a date in Syncsort
I'm trying to fix a condition in a sort but I having
difficulty on it as I hardly ever use such logic in sort.
In my input file there's a field that contains a date '20081110'.
In the sort I have to subtract 60 days from this date.
What I need to know is how to let the Sort to treat this information as a
date.
The command I'm trying to build is:
when that field (position 13, length 8 ) is different from '00010101' I
need to subtract 60 days from it and overlay the output starting at
position 13 with the result of this subtraction.
Hope someone can help, if possible.
Below is the code in which I'll insert this new command.
Code:
JOINKEYS FILE=F1,FIELDS=(1,12,A)
JOINKEYS FILE=F2,FIELDS=(1,12,A)
REFORMAT FIELDS=(F1:1,12,
F1:13,4,
F1:18,2,
F1:21,2,
F1:23,4,
F1:28,2,
F1:31,2)
INREC FIELDS=(1,12,
13,8,ZD,MAX,
21,8,ZD,
ZD,LENGTH=8)
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(13,8,CH,EQ,C'00010101'),
OVERLAY=(13:&DATENS(4MD)-60)), DATE MINUS 60 DAYS
IFTHEN=(WHEN=(13,8,CH,NE,C'00010101'),
OVERLAY=(13: NEW COMMAND WILL GO HERE)
Joined: 14 Jan 2009 Posts: 37 Topics: 0 Location: USA
Posted: Mon Nov 23, 2009 3:21 pm Post subject:
prog_mario:
At this time, SyncSort does not have a special function to perform arithmetic on input date fields. _________________ Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Mon Nov 23, 2009 8:57 pm Post subject:
prog_mario,
Just for the record, With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), DFSORT now supports the JOINKEYS as well as date conversion functions(TOGREG,TOJUL) which can perform date arithmetic and give you the desired results in one pass like shown below:
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Mon Oct 25, 2010 12:16 pm Post subject:
prog_mario,
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 add/subtract days, months or years to a given date like shown below.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
20100228 - NON LEAP YEAR DATE
20080229 - LEAP YEAR DATE
20070229 - INVALID DATE
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(40:1,8,Y4T,SUBDAYS,+60,TOGREG=(Y4T(-)))
//*
The output from the above job is
Code:
20100228 - NON LEAP YEAR DATE 2009-12-30
20080229 - LEAP YEAR DATE 2007-12-31
20070229 - INVALID DATE **********
For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at:
prog_mario:
At this time, SyncSort does not have a special function to perform arithmetic on input date fields.
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Brian, Alissa,
It is over 2 years since the original post. Does Syncsort support the arithmetic function on input date fields now? _________________ Regards,
Mangsk
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum