Showing posts with label Convert Date (CVTDAT). Show all posts
Showing posts with label Convert Date (CVTDAT). Show all posts

Wednesday, October 12, 2011

Convert Date (CVTDAT)

The Convert Date (CVTDAT) command is use to convert a Date but at the same time you can use it to check the validity of a date.

DCL VAR(&oneDat) TYPE(*CHAR) LEN(6)
DCL VAR(&OK) TYPE(*CHAR) LEN(1)
DCL VAR(&ERR) TYPE(*CHAR) LEN(8)

CHGVAR VAR(&OK) VALUE('0')

CVTDAT DATE(&oneDat) FROMFMT(*MDY) +
TOVAR(&ERR) TOFMT(*YYMD) TOSEP(*NONE)

MONMSG MSGID(CPF0550 CPF0551 CPF0552 CPF0553 +
CPF0555 CPF0556 CPF0557) +
EXEC(DO)
CHGVAR VAR(&OK) VALUE('1')
ENDDO