Problem solve Get help with specific problems with your technologies, process and projects.

CL program to Convert dates into any date format

CL program to Convert dates into any date format(Julian,YMD,DMY,YYMD,Long Julian,...)

PGM PARM(&Indate &Outdate &FmtF &FmtT)
/* assuming you want to convert MMDDYYYY into a Julian date, but the length of the variables could varied */

DCL Var(&Indate) Type(*Char)

Len(8)
DCL Var(&Outdate) Type(*Char)Len(7)
DCL Var(FmtF) Type(*Char)Len(5)
DCL Var(FmtT) Type(*Char) Len(4)

/* You can avoid logging cl command calls by using the following */ CHGJOB LOG(1 20) LOGCLPGM(*NO)

/* Use the CL command CVTDAT */
CVTDAT DATE(&Indate) TOVAR(&OutDate) FROMFMT(&FmtF) TOFMT(&FmtT)
TOSEP(*NONE)

/* Monitoring wrong dates */
MONMSG MSGID(CPF0555) EXEC(CHGVAR VAR(&OutDate) VALUE('0000000'))

RETURN

ENDPGM


Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close