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

to_timestamp example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

In other engines

Prestofrom_unixtime()

FROM_UNIXTIME(x)
In Haybarn
TO_TIMESTAMP(x)

SQLGlot example ↗

Snowflaketo_timestamp()

SELECT TO_TIMESTAMP(1659981729000000000, 9)
In Haybarn
SELECT TO_TIMESTAMP(1659981729000000000 / POWER(10, 9)) AT TIME ZONE 'UTC'

SQLGlot example ↗

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")
In Haybarn
STRFTIME(TO_TIMESTAMP(x), '%Y-%m-%d''T''%H')

SQLGlot example ↗

BigQuery

SELECT TIMESTAMP_DIFF(TIMESTAMP_SECONDS(60), TIMESTAMP_SECONDS(0), minute)
In Haybarn
SELECT DATE_DIFF('MINUTE', TO_TIMESTAMP(0), TO_TIMESTAMP(60))

SQLGlot example ↗