I need to convert western current date "20151104" to "1041104",which is the date format of my country - Republic of Chinese (Taiwan).
The syntax I used :
Code:
OUTFIL BUILD=(DATE1,SUB,+19110000,TO=CH,LENGTH=6)
and, the error message :
Code:
********************************* TOP OF DATA **********************************
ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001
ICE805I 0 JOBNAME: YBAI1099 , STEPNAME: S0
ICE802I 0 BLOCKSET TECHNIQUE IN CONTROL
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 16:22 ON WED NO
* OUTFIL OVERLAY=(139:(DATE1P,SUB,+20110000,M11,LENGTH=6))
OUTFIL BUILD=(DATE1,SUB,+20110000,TO=CH,LENGTH=6)
$
ICE007A E SYNTAX ERROR
* OUTFIL BUILD=(DATE1P,TO=CH,LENGTH=8)
ICE146I 0 END OF STATEMENTS FROM CTR1CNTL - PARAMETER LIST STATEMENTS FOLLOW
Is it possible to treate DATE1P as a number in arithmetic expression?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Application Programming Guide wrote:
DATE1, &DATE1, DATE1(c), DATE1(c), DATE2, &DATE2, DATE2(c), &DATE2(c), DATE3, &DATE3, DATE3(c) or &DATE3(c) can be used to generate a character constant for the current date of the run. DATE1P, &DATE1P, DATE2P, &DATE2P, DATE3P or &DATE3P can be used to generate a packed decimal constant for the current date of the run.
Also, you say TO=CH, you want TO=ZD, and your LENGTH=6 will cause truncation.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I didn't do such a good job of formatting the quote from the manual, so I've fixed that.
You can't do arithmetic with a "character" field.
You can't do arithmetic, like that, with a date-constant.
With a date-constant, modification by a number of days or months to give a future or past date is possible, it is built in. However, there is a limit of 9999 days, or months, that you can modify by. Your 1911 years would be too many months.
Quote:
Is it possible to treat DATE1P as a number in arithmetic expression?
No. So you have to do it a different way.
It looks as though you are just testing to use the code later. So your final code may be different.
It is the second IFTHEN which is significant and which makes the amendment to the year portion of a date.
The first IFTHEN puts the 8-character date into the current record.
The third IFTHEN shifts the data left so that you get your seven-character date in the first seven positions.
The IFOUTLEN=7 says "once IFTHEN processing is complete, make the record-length seven".
If you can provide an example of how you want to actually use this, some more directly relevant code can be provided.
I assume that you have realised you must only do this conversion of the date as the last thing. If you were to convert early, or take already converted data and use DFSORT's date functions, you will not (always) get the correct result, because your starting-point year is not going to allow the correct calculation of leap-years for the date functions.