On this page

    Categories: Date/Time, System

    UNIX_TIMESTAMP

    Returns the Unix epoch time representation of an ISO 8601 timestamp.

    Syntax

    UNIX_TIMESTAMP() → int64

    Examples

    UNIX_TIMESTAMP example
    SELECT UNIX_TIMESTAMP()
    -- 1624928208
    

    UNIX_TIMESTAMP(date_timestamp_expression varchar) → int64

    • date_timestamp_expression: The timestamp to convert to Unix timestamp. The expected format is ‘YYYY-MM-DD HH:MM:SS’ where HH can be a value 1-24.

    Examples

    UNIX_TIMESTAMP example
    SELECT UNIX_TIMESTAMP('2021-12-22 13:44:11')
    -- 1640180651
    

    UNIX_TIMESTAMP(date_timestamp_expression varchar, format varchar) → int64

    • date_timestamp_expression: The timestamp to convert to Unix timestamp.
    • format: Specify the format of the time, date, or timestamp parameter. For example, ‘YY-MM-DD’ or ‘HH:MM:SS’.

    Examples

    UNIX_TIMESTAMP example
    SELECT UNIX_TIMESTAMP('21-12-22', 'YY-MM-DD')
    -- 1640131200