420 pts.
 CL Programming
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
ASKED: June 5, 2012  9:36 AM
UPDATED: June 7, 2012  5:04 AM
  Help
 Approved Answer - Chosen by anupsshelke (Question Asker)

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

ANSWERED:  Jun 6, 2012  4:27 AM (GMT)  by anupsshelke

 
Other Answers:

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

Last Wiki Answer Submitted:  June 5, 2012  12:34 pm  by  CharlieBrowne   32,855 pts.
Latest Answer Wiki Contributors:  CharlieBrowne   32,855 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


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


 

yes sir definitely
CAN WE USED LENGTH 4 IN PLACE LENGTH 2 ?
IF YES THEN HOW?
IF NOT THEN WHY?

 420 pts.

 

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,055 pts.

 

thank you sir

 420 pts.