How to format a date to custom format in jcl



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

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.

SORT FIELDS=COPY
OUTREC BUILD=(DATE1-1095)
deva_048
 
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Has thanked: 1 time
Been thanked: 0 time

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

 

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
NicC
Global moderator
 
Posts: 2702
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

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
deva_048
 
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Has thanked: 1 time
Been thanked: 0 time

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.
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)     
Thampy
 
Posts: 35
Joined: Sat Sep 26, 2009 2:27 pm
Has thanked: 0 time
Been thanked: 3 times

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

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

//SORTIN DD *
DUMMY
/*
//SORTOUT DD SYSOUT=*
//SYSIN       DD *
                  SORT FIELDS=COPY
                  INREC BUILD=(DATE1-1095)
                  OUTREC BUILD=(3,6)
/*
deva_048
 
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Has thanked: 1 time
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post