function
Library: Date and time functions (OMDATE)
Include: omdate.xin |
Returns: a specified date/time rounded up to the nearest indicated interval |
define string function round-up-ymdhms value string ymdhms to value string interval
Argument definitions
YYYYMMDDhhmmss+ZHZM
format round-up-ymdhms
takes a date/time in YYYYMMDDhhmmss+ZHZM
format and returns the same
value, but rounded up to the end of an interval as 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 up to the nearest month.
include "omdate.xin" process local string now set now to now-as-ymdhms output "Now, unrounded = " || now || "%n" || "Now, rounded up to the month = " || round-up-ymdhms now to "mo" || "%n"Running this example might yield output such as
Now, unrounded = 20191031160045-0400 Now, rounded up to the month = 20191031235959-0400
To use round-up-ymdhms
, you must include the following code near the top of your program:
include "omdate.xin"