Solved

CL PROGRAM TO CONVERT QDATE

Posted on 2009-06-29
1
1,964 Views
Last Modified: 2013-12-06
I need a simple CL program to convert the current date (QDATE) into the format YYYYMMDD that I can store in a text file.
The existing code is extracting a 2 digit year.

Thanks
0002.00              DCL        VAR(&PDATE) TYPE(*CHAR) LEN(6)
0004.00              DCL        VAR(&CJULIAN) TYPE(*CHAR) LEN(5)
0005.00              DCL        VAR(&DJULIAN) TYPE(*DEC) LEN(6)
0006.00              ADDLIBLE   LIB(PIPRD)
0007.00              MONMSG     MSGID(CPF2100)
0008.00
0009.00
0010.00              RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&PDATE)
0011.00              CVTDAT     DATE(&PDATE) TOVAR(&CJULIAN) FROMFMT(*MDY) +
0012.00                           TOFMT(*JUL) TOSEP(*NONE)
0013.00              CHGVAR     VAR(&DJULIAN) VALUE(&CJULIAN)
0014.00              CHGVAR     VAR(&DJULIAN) VALUE(&DJULIAN + 1)
0015.00  CONVERT:    CHGVAR     VAR(&CJULIAN) VALUE(&DJULIAN)
0016.00              CVTDAT     DATE(&CJULIAN) TOVAR(&PDATE) FROMFMT(*JUL) +
0017.00                           TOFMT(*YMD) TOSEP(*NONE)
0018.00              MONMSG     MSGID(CPF0555) EXEC(DO)
0019.00              CHGVAR     VAR(&DJULIAN) VALUE(1)
0020.00              GOTO       CMDLBL(CONVERT)
0021.00              ENDDO

Open in new window

0
Comment
Question by:a016691
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 24736845
Use CVTDAT to convert the retrieved QDATE value from *SYSVAL format to *YYMD format, or retrieve QDATETIME instead (20A) and substring out the first 8 characters.

- Gary Patterson
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question