CL Programming

420 pts.
Tags:
AS/400
PGM
PGM 
                  DCL VAR(&TIME) TYPE(*CHAR) LEN(6) 
                  DCL VAR(&DATE) TYPE(*CHAR) LEN(6) 
                  DCL VAR(&YEAR) TYPE(*CHAR) LEN(2) 
                  RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIME) 
                  RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATE) 
                  RTVSYSVAL SYSVAL(QYEAR) RTNVAR(&YEAR) 
                  SNDPGMMSG MSG('TIME IS' *BCAT &TIME) 
                  SNDPGMMSG MSG('DATE IS' *BCAT &DATE) 
                  SNDPGMMSG MSG('YEAR IS' *BCAT &YEAR) 
                  ENDPGM.
I have written code for fetch curreent date, time and year .
when i write length is 4 for year in place then it shows error .
Can we used length 4 ?


Software/Hardware used:
software

Answer Wiki

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

QYEAR is onlyh a 2 position value.
To get the century you would also need to retrievfe QCENTURY

Other options are to use the Job Date or Timestamp

Discuss This Question: 5  Replies

 
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
  • anupsshelke
    yes sir definitely CAN WE USED LENGTH 4 IN PLACE LENGTH 2 ? IF YES THEN HOW? IF NOT THEN WHY?
    420 pointsBadges:
    report
  • bvining
    Rather than retrieving QDATE, QTIME, and QYEAR you could just retrieve QDATETIME. QDATETIME is a CHAR(20) from which you can substring out the 4-digit year, the date, and the time.
    6,495 pointsBadges:
    report
  • TomLiotta
    CAN WE USED LENGTH 4 IN PLACE LENGTH 2 ? No. IF NOT THEN WHY? Because it is defined by the system with a length of 2. This isn't the definition of a 'year', but it is the definition of the QYEAR system value. If you use a system value, you must use the defined length. The <help> text for the RTNVAR() parameter of the RTVSYSVAL command tells you the acceptable lengths of all system values. As others have said, a 4-digit year value can be accessed in other ways, but not with QYEAR. Tom
    125,585 pointsBadges:
    report
  • anupsshelke
    thank you sir
    420 pointsBadges:
    report
  • anupsshelke
    [...] 3. The trio of Bvining, CharlieBrowne and TomLiotta help Anupsshelke correct an AS/400 code to fetch the current date, time and year. [...]
    0 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