TO_UNIXTIME()

All functions > DATE AND TIME > TO_UNIXTIME()

Returns a unix timestamp (BIGINT representation of the number of seconds since 1970-01-01 00:00:00 UTC) from the given date or timestamp.

Signatures

Returns: Unix timestamp as DECIMAL (seconds since epoch)

TO_UNIXTIME(timestamp: DATE | TIMESTAMP) → DECIMAL
sql
ParameterTypeRequiredDescription
timestamp`DATETIMESTAMP`Yes

Notes

  • Converts DATE or TIMESTAMP to Unix epoch seconds
  • Returns seconds since January 1, 1970 00:00:00 UTC
  • DATE inputs are treated as midnight (00:00:00) on that day
  • Result is a DECIMAL to preserve sub-second precision
  • Useful for interoperability with systems using Unix timestamps
  • Inverse of FROM_UNIXTIME

Aliases

  • EPOCH

Examples

FeatureQL
SELECT
    f1 := TO_UNIXTIME(DATE '2024-03-15')::VARCHAR, -- Date treated as midnight (as text for stable SLT shape)
    f2 := TO_UNIXTIME(DATE '1970-01-01')::VARCHAR, -- Unix epoch date yields 0
    f3 := TO_UNIXTIME(TIMESTAMP '2024-03-15 09:50:00')::VARCHAR -- Timestamp with time component (as text for stable SLT shape)
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
1710460800.00.01710496200.0

Last update at: 2026/05/26 17:22:09