On this page

    Categories: Date/Time, Context

    UNIX_TIMESTAMP

    Returns the Unix timestamp for the timestamp parameter.

    Syntax

    UNIX_TIMESTAMP() → int64

    Examples

    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

    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

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