Links

TO_DATE

Converts the input expressions to the corresponding date.

Syntax

TO_DATE(in timestamp) → date

  • in: The date is extracted from the timestamp.
Examples
TO_DATE example
SELECT TO_DATE(TIMESTAMP '2022-05-17 19:15:00.000')
-- 2022-05-17

TO_DATE(numeric_expression int32) → date

  • numeric_expression: A Unix epoch timestamp.
Examples
TO_DATE example
SELECT TO_DATE(1640131200)
-- 2021-12-22

TO_DATE(numeric_expression float) → date

  • numeric_expression: A Unix epoch timestamp.
Examples
TO_DATE example
SELECT TO_DATE(1665131223.69)
-- 2022-10-07

TO_DATE(numeric_expression int64) → date

  • numeric_expression: A Unix epoch timestamp.
Examples
TO_DATE example
SELECT TO_DATE(1640131200)
-- 2021-12-22

TO_DATE(string_expression varchar, format varchar, replaceErrorWithNull int32) → date

  • string_expression: The string from which to extract the date.
  • format: String to specify format of the date.
  • replaceErrorWithNull: If 0, the function will fail when given malformed input. If 1, the function will return NULL when given the malformed input.
Examples
TO_DATE example
SELECT TO_DATE('2022-07-22.23', 'YYYY-MM-DD', 1)
-- NULL

TO_DATE(string_expression varchar, format varchar) → date

  • string_expression: String from which to extract the date.
  • format: String to specify format of the date.
Examples
TO_DATE example
SELECT TO_DATE('05/24/22', 'MM/DD/YY')
-- 2022-05-24

TO_DATE(numeric_expression double) → date

  • numeric_expression: A Unix epoch timestamp.
Examples
TO_DATE example
SELECT TO_DATE(1665131223.69)
-- 2022-10-07
Last modified 10mo ago