Categories: Date/Time, Conversion

TO_TIMESTAMP

Converts the input expressions to the corresponding timestamp.

Syntax

TO_TIMESTAMP(numeric_expression double) → timestamp

  • numeric_expression: The Unix format of the timestamp.

Examples

SELECT TO_TIMESTAMP(52 * 365.25 * 86400)
-- 2022-01-01 00:00:00

TO_TIMESTAMP(string_expression varchar, format varchar, replaceWithNullHolder int32) → timestamp

  • string_expression: The string from which to extract the timestamp.
  • format: String to specify format of the timestamp.
  • replaceWithNullHolder: sample parameter description

Examples

SELECT TO_TIMESTAMP('2021-07-31 01:02:03', 'YYYY-MM-DD HH:MI:SS', 'FILL_IN')
-- 2021-07-31 01:02:03

TO_TIMESTAMP(numeric_expression int64) → timestamp

  • numeric_expression: The Unix format of the timestamp.

Examples

SELECT TO_TIMESTAMP(1640131200)
-- 2021-12-22 00:00:00

TO_TIMESTAMP(numeric_expression int32) → timestamp

  • numeric_expression: The Unix format of the timestamp.

Examples

SELECT TO_TIMESTAMP(1640131200)
-- 2021-12-22 00:00:00

TO_TIMESTAMP(numeric_expression float) → timestamp

  • numeric_expression: The Unix format of the timestamp.

Examples

SELECT TO_TIMESTAMP(52 * 365.25 * 86400)
-- 2022-01-01 00:00:00

TO_TIMESTAMP(string_expression varchar, format varchar) → timestamp

  • string_expression: String from which to extract the timestamp from.
  • format: String to specify format of the timestamp.

Examples

SELECT TO_TIMESTAMP('2021-07-31 01:02:03', 'YYYY-MM-DD HH:MI:SS')
-- 2021-07-31 01:02:03

Learn more about date/time formatting.