Skip to main content
Scalar function
Aliases: unix_timestamp, to_unixtime NULL timestamp, value or format yields NULL. Invalid string/timezone conversion raises an error.

Syntax

Timestamp (scalar)

Parsed (scalar)

Unix timestamp timestamp (scalar)

Unix timestamp parsed (scalar)

To unixtime timestamp (scalar)

  • TO_UNIXTIME accepts exactly one TIMESTAMP operand. No no-argument/string parsing form.

Arguments

Timestamp, unix timestamp timestamp, to unixtime timestamp

Parsed, unix timestamp parsed

Returns

  • Type: BIGINT
  • NULL behavior: NULL timestamp, value or format yields NULL. Invalid string/timezone conversion raises an error.

To unixtime timestamp

  • Type: BIGINT
  • NULL behavior: NULL timestamp, value or format yields NULL. Invalid string/timezone conversion raises an error.

Properties

Units

  • Input unit: Timestamp or formatted text
  • Output unit: Signed seconds since Unix epoch UTC
  • Microseconds / 1000000, truncating toward zero.

Usage notes

  • Fractional seconds are truncated toward zero, including negative epoch values.
  • Pass a TIMESTAMP, or pass a STRING together with its format. An unformatted STRING is not part of these calling forms.

Examples

Basic example

Alias calling form: UNIX_TIMESTAMP

Alias calling form: TO_UNIXTIME

Limitations

  • TO_UNIXTIME accepts a TIMESTAMP. The STRING-with-format, DATE, unformatted STRING, and no-argument forms are not available through this alias.
Last modified on October 15, 2026