System Date in COBOL/400
How to get the system date in the format of CCYYMMDD(*ISO) or MMDDCCYY(*USA) same like RPG400? Can anyone pls help?

Software/Hardware used:
ASKED: April 16, 2008  10:25 AM
UPDATED: May 6, 2010  1:24 PM

Answer Wiki:
I would suggest reviewing the <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/books/sc092539.pdf">ILE COBOL Reference</a> and in the chapter on Procedure Division Statements the description of ACCEPT identifer-1 FROM DATE YYYYMMDD. You may also want to explore the chapter on Intrinsic Functions. Bruce Vining <a href="http://www.brucevining.com/">http://www.brucevining.com/</a> Providing integrated solutions for the System i user community ACCEPT <field> from DATE will only return a date in YYMMDD format. To get the full system date, try this.... Identification Division. Program-Id. TimeDateCB. Author. Charles Siu. Environment Division. Configuration Section. Source-Computer. AS400. Object-Computer. AS400. Data Division. Working-Storage Section. 01 Current-Timestamp. 05 Current-Year Pic 9(4). 05 Current-Month Pic 9(2). 05 Current-Date Pic 9(2). 05 Current-Hour Pic 9(2). 05 Current-Minute Pic 9(2). 05 Current-Second Pic 9(2). 05 Current-100thSec Pic 9(2). 05 GMT-Variation Pic X. 05 GMT-Hour-Difference Pic 9(2). 05 GMT-Min-Difference Pic 9(2). Procedure Division. MOVE FUNCTION CURRENT-DATE TO Current-Timestamp. STOP RUN. By the way, I am an RPG programmer too, in search of COBOL/400 knowledge.
Last Wiki Answer Submitted:  May 5, 2010  3:40 pm  by  bvining   6,055 pts.
All Answer Wiki Contributors:  bvining   6,055 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

01 WS-DATE.
05 WS-CC PIC 9(002).
05 WS-YY PIC 9(002).
05 WS-MM PIC 9(002).
05 WS-DD PIC 9(002).

01 ISO-TODAY
FORMAT DATE “@Y-%m-%d”.

ACCEPT WS-DATE FROM DATE YYYYMMDD.

MOVE FUNCTION CONVERT-DATE-TIME ( WS-DATE DATE “%Y%m%d” )
TO ISO-TODAY.

 445 pts.