TIME function

Returns an INTEGER value representing the time as the number of seconds since midnight. Use this function together with the STRING function to produce the time in hours, minutes, and seconds.

Syntax

TIME

Example

In r-time.p, the timeleft variable is set to the result of the TIME function subtracted from the number of seconds in a day. The procedure translates this value into seconds, minutes, and hours.

r-time.p

DEFINE VARIABLE hour     AS INTEGER NO-UNDO.
DEFINE VARIABLE minute   AS INTEGER NO-UNDO.
DEFINE VARIABLE sec      AS INTEGER NO-UNDO.
DEFINE VARIABLE timeleft AS INTEGER NO-UNDO.

timeleft = (24 * 60 * 60) - TIME.  

/* seconds till next midnight */
sec = timeleft MOD 60.
timeleft = (timeleft - sec) / 60. 
 
/* minutes till next midnight */
minute = timeleft MOD 60.

/* hours till next midnight */
hour = (timeleft - minute) / 60.   

DISPLAY "Time to midnight:" hour  minute  sec .

This DISPLAY statement displays the current time.

r-time2.p

DISPLAY STRING(TIME,"HH:MM:SS").

See also

ADD-INTERVAL function, DATE function, DATE-FORMAT attribute, DATETIME function, DATETIME-TZ function, DAY function, ETIME function, INTERVAL function, ISO-DATE function, MONTH function, MTIME function, NOW function, TIME-SOURCE attribute, TIMEZONE function, TODAY function, WEEKDAY function, YEAR function, YEAR-OFFSET attribute