| Date/Time Functions |
|
|
| Written by Admin (Chamara) | |
| Apr 02, 2009 at 02:04 AM | |
|
IBM introduced the %DATE, %TIME, and %TIMESTAMP built-in functions even before V5.1 and /FREE syntax. this will replace the TIME opcode, and also you can do more using these Builtin functions
to use these built-in functions, you simply declare a date, time, or timestamp variable and then use the EVAL opcode to copy the value into the variable. For example: D myDat S D D myTim S T /free myDate = %date(); // current system date myTime = %time(); // current system time /end-free Get the Job Date To retrieve the job date instead of the system date To accomplish this with the built-in functions, you need to go back in time and dust off the UDATE figurative constant and wrap it in %DATE, see following example
D myDate S D /free myDate = %date(UDATE); // job date /end-free Timestamp You can use the TIME opcode to populate timestamp fields just like date and time fields. However, you can also use the %TIMESTAMP built-in function with identical results. for example:
FUserMast UF A E K DISK D myDate S D /free crtdate = %timestamp(); // timestamp write custRec; /end-free %TimeStamp() returns 26 characters of information: the date and the time with six characters of microseconds; however, only three digits of the microseconds (i.e., milliseconds) are accurate, the remaining three are always set to zero. |
| <Previous |
|---|