Date-Time Functions

The functions described in this section operate on fields in date-time format (sometimes called H format). However, you can also provide a date as a character string using the macro DT, followed by a character string in parentheses, presenting date and time. Date components are separated by slashes '/'; time components by colons ':'.

Alternatively, the day can be given as a natural day, like 2004 March 31, in parentheses. Either the date or time component can be omitted. For example, the date-time format argument can be expressed as DT(2004/03/11 13:24:25.99) or DT(March 11 2004).

The following is another example that creates a timestamp representing the current date and time. The system variables &YYMD and &TOD are used to obtain the current date and time, respectively:

-SET &MYSTAMP = &YYMD | ' ' | EDIT(&TOD,'99:$99:$99') ;

Today's date (&YYMD) is concatenated with the time of day (&TOD). The EDIT function is used to change the dots (.) in the time of day variable to colons (:).

The following request uses the DT macro on the alphanumeric date and time variable &MYSTAMP:

TABLE FILE CAR 
  PRINT CAR NOPRINT 
  COMPUTE   DTCUR/HYYMDS = DT(&MYSTAMP);
  IF RECORDLIMIT IS 1; 
END 

The following are date-time functions:


iWay Software