System Date in COBOL/400

Tags:
AS/400
CCYYMMDD
COBOL
MMDDCCYY
RPG
How to get the system date in the format of CCYYMMDD(*ISO) or MMDDCCYY(*USA) same like RPG400? Can anyone pls help?
ASKED: April 16, 2008  10:25 AM
UPDATED: May 6, 2010  1:24 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Rlsantucijr
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following