Constructing date and time values

EQL provides functions to construct a timestamp representing time, date, or duration using an expression.

If the expression is a string, it must be in a certain format. If the format is invalid or the value is out of range, it results in NULL.

Function Description Format
TO_TIME Constructs a timestamp representing time.

<Time String Format> ::= hh:mm:ss[.sss]((+|-) hh:mm |Z)

TO_DATETIME Constructs a timestamp representing date and time.

<DateTime String Format> ::= [-]YYYY-MM-DDT<Time String Format>

TO_DURATION Constructs a timestamp representing duration.

<Duration String Format> ::=

[-]P[<Days>][T(<Hours>[<Minutes>}[<Seconds>]|

<Minutes>[<Seconds>]|

<Seconds>)]

<Days> ::= <Integer>D

<Hours> ::= <Integer>H

<Minutes> ::= <Integer>M

<Seconds> ::= <Integer>[.<Integer>]S

As stated in the Format column above, TO_TIME and TO_DATETIME accept time zone offset. However, EQL does not store the offset value. Instead, it stores the value normalized to the GMT timezone.

The following table shows the output of several date and time expressions:

Expression Normalized value
TO_DATETIME('2012-03-21T16:00:00.000+02:00') 2012-03-21T14:00:00.000Z
TO_DATETIME('2012-12-31T20:00:00.000-06:00') 2013-01-01T02:00:00.000Z
TO_DATETIME('2012-06-15T20:00:00.000Z') 2012-06-15T20:00:00.000Z
TO_TIME('23:00:00.000+03:00') 20:00:00.000Z
TO_TIME('15:00:00.000-10:00') 01:00:00.000Z