function
Library: Date and time functions (OMDATE)
Include: omdate.xin |
Returns: the specified date/time rounded down to the nearest indicated interval |
define string function round-down-ymdhms value string ymdhms to value string interval
Argument definitions
YYYYMMDDhhmmss+ZHZM
format. round-down-ymdhms
takes a date/time in YYYYMMDDhhmmss+ZHZM
format, and returns the same value
but rounded down to the beginning of an interval indicated by the second argument. Only the shortest
distinguishing prefix of the interval name is needed, so y
can be used in place of year
,
but mo
and mi
are needed to distinguish between month
and minute
. This argument can be in either uppercase or lowercase. If this argument is unrecognized, the date/time
will be returned unchanged.
The following program takes the current date/time, and rounds it down to the nearest minute.
include "omdate.xin" process local string now set now to now-as-ymdhms output "Now, unrounded = " || now || "%n" || "Now, rounded down to the minute = " || round-down-ymdhms now to "mi" || "%n"Running this example might yield output such as
Now, unrounded = 20191031155546-0400 Now, rounded down to the minute = 20191031155500-0400
To use round-down-ymdhms
, you must include the following code near the top of your program:
include "omdate.xin"