Using timestamp fields

The Timestamp built-in function came about in V5R1.  It can be expressed with separators (*ISO) or without (*ISO0).   

The format of a timestamp field is

Timestamp defined in File DDS:
A             CDateTS        Z     TEXT('Timestamp of file changes')

Timestamp defined in RPG Data specifications and initialized to the current system date/time:
D CDateTS         s                                               z   inz(*sys)  

Traditional RPGLE (current date and time):
C            eval CDateTS = %timestamp()

Free format RPG (current date and time):
    CDateTS = %timestamp();

How many days apart are two dates:
      TodayTS = %timestamp();

      Daysdiff = %diff(FilDateTS:TodayTS:*days)

Many operations that are used on date fields also work with timestamps.  For example, MOVE, MOVEL, TEST, SUBDUR, and ADDDUR can all be used with timestamps.

Example of converting a Timestamp field to a date field:

d zdate        s                 z
d ndate        S                 D

c                    eval  zdate=%timestamp()
c                    eval  ndate=%date(zdate)

c      ndate         dsply
c                    exsr           $exit