How to format a date to custom format in jcl

Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL
deva_048
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Skillset: JCL, COBOL
Referer: peterh

How to format a date to custom format in jcl

Postby deva_048 » Thu Oct 30, 2014 4:32 pm

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.

Code: Select all

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

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

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

Postby NicC » Thu Oct 30, 2014 6:47 pm

Looks like you have subtracte 2 years 1 month and 29 days in your example. Where is the 3 years?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

deva_048
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Skillset: JCL, COBOL
Referer: peterh

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

Postby deva_048 » Thu Oct 30, 2014 6:54 pm

Sorry the o/p i mentioned above is wrong.. It is 111031 instead of 120901

Thampy
Posts: 36
Joined: Sat Sep 26, 2009 2:27 pm
Skillset: Cobol,Jcl,Vsam,Db2,Ideal,Datacom
Referer: My colleagues informed about this forum

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

Postby Thampy » Thu Oct 30, 2014 8:04 pm

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.

Code: Select all

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.

Code: Select all

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

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

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

Postby BillyBoyo » Thu Oct 30, 2014 9:21 pm

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.

deva_048
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Skillset: JCL, COBOL
Referer: peterh

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

Postby deva_048 » Fri Oct 31, 2014 10:09 am

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

Code: Select all

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


  • Similar Topics
    Replies
    Views
    Last post