Back to Browse

JCL - Sort part4 (Date handling)

3.1K views
Jun 8, 2019
3:22

How to use the current date as a string in DFSORT Following are the commonly used date format in DFSORT. If the current date date is 27th May 2019, the date value returned will be DATE1 'yyyymmdd' 20190527 DATE1(c) 'yyyycmmcdd' 2019c05c27 DATE2 'yyyymm' 201905 DATE2(c) 'yyyycmm' 2019c05 DATE3 'yyyyddd' 2019147 (27-May-2019) DATE3(c) 'yyyycddd' 2019C147 DATE4 'yyyy-mm-dd-hh.mm.ss' DATE4 'yyyy-mm-dd-hh.mm.ss' DATE5 'yyyy-mm-dd-hh.mm.ss.nnnnnn' you can generate or test the record based on a current date with the provided format. OPTION COPY OUTREC BUILD=(DATE1) Use this statement in your sort control card If the current date is in a decimal format you can use DATE1P, DATE2P or DATE3P as follows. DATE1P +yyyymmdd +20190527 DATE2P +yyyymm +201905 DATE3P +yyyyddd +2019147 If you want to handle the previous date or a future date, you can use the below logic. DATE1P-10 will return the value as +20190517 in decimal format. The current date is 27-05-2019 DATE1P+02 will return the value as +20190529 in decimal format. My input file contains a date field. I want to replace the value in the date field with the current date value. How can I do it in the JCL program? Ans: One of the possible ways is to OVERLAY with the current date value as follows. If you know any other possible ways, please share it in the comments section of this video. For Character type: Start Pos:100 Length : 10 SORT FIELDS=COPY INREC IFTHEN=(WHEN=(100,10,CH,NE,C' '), OVERLAY=(100:C'2020-03-08')) Exercise: Use the above JCL control card, replace the date value with current date value using the given date format

Download

0 formats

No download links available.

JCL - Sort part4 (Date handling) | NatokHD