Page 1 of 1

How to format a date to custom format in jcl

PostPosted: Thu Oct 30, 2014 4:32 pm
by deva_048
need to subtract 3 years from input. and populate the o/p file in mentioned format
I/P :
2014-10-30

O/P:
120901

I have used the below code to subtract three years from the input file. Let me know your suggestions please to subtract and populate the o/p in yymmdd format.

SORT FIELDS=COPY
OUTREC BUILD=(DATE1-1095)

Re: How to format a date to custom format in jcl

PostPosted: Thu Oct 30, 2014 6:47 pm
by NicC
Looks like you have subtracte 2 years 1 month and 29 days in your example. Where is the 3 years?

Re: How to format a date to custom format in jcl

PostPosted: Thu Oct 30, 2014 6:54 pm
by deva_048
Sorry the o/p i mentioned above is wrong.. It is 111031 instead of 120901

Re: How to format a date to custom format in jcl

PostPosted: Thu Oct 30, 2014 8:04 pm
by Thampy
I assume your SORTIN contain the date in ccyy-mm-dd format and its stored in positions 1-10. The below Syncsort sysin card subtract 3 years from the input file and write the output in yymmdd format.
SORT FIELDS=COPY                                       
  INREC OVERLAY=(1:DATEADD=(1,10,DT=(4MD-),-3,YEAR))     
  OUTREC BUILD=(3,2,6,2,9,2)


If you are having Syncsort V.1.4.2, then you case make use of SUBYEARS parameter.

 SORT FIELDS=COPY                                       
  INREC OVERLAY=(1:1,10,UFF,ZD,LENGTH=8,                 
          1:1,8,Y4T,SUBYEARS,+3,TOGREG=Y2T)             
  OUTREC BUILD=(1,6)     

Re: How to format a date to custom format in jcl

PostPosted: Thu Oct 30, 2014 9:21 pm
by BillyBoyo
Ensure that any definition of "Year" in the spec matches with what is available to SyncSORT. If SyncSORT doesn't have it directly, you can always adjust it.

Re: How to format a date to custom format in jcl

PostPosted: Fri Oct 31, 2014 10:09 am
by deva_048
Thanks all for your response.
But i am using below code to get current date but there is no specified format in input file. So DATE1 will get current date from the system format yyyymmdd. If you have any other solution. Please suggest me

//SORTIN DD *
DUMMY
/*
//SORTOUT DD SYSOUT=*
//SYSIN       DD *
                  SORT FIELDS=COPY
                  INREC BUILD=(DATE1-1095)
                  OUTREC BUILD=(3,6)
/*