Dates & time
Scalar
to_timestamp()
Converts secs since epoch to a timestamp with time zone
Arguments & returns
to_timestamp(sec)
Scalar
| Overload link | sec |
Returns |
|---|---|---|
| #01 | DOUBLE |
TIMESTAMP WITH TIME ZONE |
Example
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
In other engines
Snowflaketo_timestamp()
SELECT TO_TIMESTAMP(1659981729000000000, 9)
SELECT TO_TIMESTAMP(1659981729000000000 / POWER(10, 9)) AT TIME ZONE 'UTC'
Used in larger rewrites 2
These examples use to_timestamp as one part of a larger SQL translation.
Apache Hivefrom_unixtime()
from_unixtime(x, "yyyy-MM-dd'T'HH")
STRFTIME(TO_TIMESTAMP(x), '%Y-%m-%d''T''%H')
BigQuery
SELECT TIMESTAMP_DIFF(TIMESTAMP_SECONDS(60), TIMESTAMP_SECONDS(0), minute)
SELECT DATE_DIFF('MINUTE', TO_TIMESTAMP(0), TO_TIMESTAMP(60))