Date and Time Functions
AMPS includes functions for working with date and time values. This section covers functions loaded into AMPS by default. AMPS also includes functions for working with date and time in the Legacy Messaging Compatibility layer.
STRFTIME
STRFTIME
STRFTIME(format_string, timestamp)
Produces a string that contains a representation of the provided timestamp
, formatted as specified in the provided format_string
.
Parameters
format_string
: The format string, using the same format specifiers as the standardstrftime(3)
function. This function also supports the additional format specifier%f
to format microseconds, and the format specifier%03f
to format milliseconds.timestamp
: The timestamp to format.
Returns
A formatted string representation of the timestamp. The length of the string produced for the time is limited to 128 bytes.
STRPTIME
STRPTIME
STRPTIME(time_string, format_string)
This function interprets the time_string
provided as a timestamp, with the format_string
specifying how to interpret the time_string
.
Parameters
time_string
: The string containing a timestamp to parse.format_string
: The format string, using the same format specifiers as the standardstrptime(3)
function. This function also supports the additional format specifier%f
to parse microseconds, and the format specifier%03f
to parse milliseconds.
Returns
A double representing the parsed timestamp.
UNIX_TIMESTAMP
UNIX_TIMESTAMP
UNIX_TIMESTAMP()
Returns the current timestamp as a double, represented in seconds (including parts of a second as a decimal).
A UNIX timestamp is seconds elapsed since 00:00 on January 1, 1970 in UTC and is independent of the timezone of the local system.
The underlying system call used for this function has microsecond resolution, subject to any hardware or host limitations.
This function is non-deterministic, and cannot be used in contexts that require a deterministic function.
Parameters
None.
Returns
A double representing the current UNIX timestamp.