IBMi (AS400) fans only - How to get today's date from CL (Control Language)







 
#IBMiSample

This example gets todays date in format YYMMDD without separators.

With simple changes you get other formats.

             PGM                                              
             DCL        VAR(&DATE) TYPE(*CHAR) LEN(6)         
             RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&DATE)           
             CVTDAT     DATE(&DATE) TOVAR(&DATE) FROMFMT(*MDY)
                          TOFMT(*YMD) TOSEP(*NONE)            
             SNDPGMMSG MSG(&DATE)                             
             ENDPGM                                           

Comments

  1. If you want the power of db2 date format or calculations you can write a view with the necessary fields and retrieve this in clle. https://github.com/prsbrc/Miscellaneous/tree/master/Receive%20view%20in%20cl%20example

    ReplyDelete
  2. It strikes me as funny that QDATE is stored as MDY - am I correct in thinking that the USA is the only country in the world that uses this format?

    ReplyDelete

Post a Comment

Popular posts from this blog

IBMi (AS400) fans only ‘ Memories (IBM Coding Forms)

IBMi (AS400) fans only ' SQLCODE values: Dear readers, unleash your suggestions!