Date / Time Functions - Amazon Timestream

Date / Time Functions

Timestream only supports the timestamp and interval data types for date/time data types.

Note

Timestream does not support negative time values. Any operation resulting in negative time results in error.

Timestream supports the following functions on timestamps and intervals:

Function Output data type Description

current_date

timestamp

Returns Timestamp for UTC 00:00:00 for the current day.

current_timestamp or now()

timestamp

Returns Timestamp for current time in UTC.

from_iso8601_timestamp(string)

timestamp

Parses the ISO 8601 timestamp into internal timestamp format.

from_iso8601_date(string)

timestamp

Parses the ISO 8601 date string into internal Timestamp format for UTC 00:00:00 of the specified date.

to_iso8601(x)

varchar

Returns an ISO 8601 formatted string for the input timestamp x.

date_trunc(unit, timestamp)

timestamp

Returns the timestamp truncated to unit, where unit is one of [second, minute, hour, day, week, month, quarter, or year].

parse_duration(string)

interval

Parses the input string to return an interval equivalent.

bin(timestamp, interval)

timestamp

Rounds value down to a multiple of the given bin interval.

ago(interval)

timestamp

Returns the value corresponding to current_timestamp interval.

interval literals such as 1h, 1d, 30m, etc.

interval

Interval literals are a convenience for parse_duration(string). For example, 1d is the same as parse_duration('1d'). This allows the use of the literals wherever an interval is used. For example, ago(1d) and bin(time, 1m).