Skip to content

Latest commit

 

History

History
101 lines (71 loc) · 2.76 KB

File metadata and controls

101 lines (71 loc) · 2.76 KB
description
Converts the input expressions to the corresponding date.

TO_DATE

Syntax

TO_DATE(in timestamp) → date

  • in: The date is extracted from the timestamp.

Examples

{% code title="TO_DATE example" %}

SELECT TO_DATE(TIMESTAMP '2022-05-17 19:15:00.000')
-- 2022-05-17

{% endcode %}

TO_DATE(numeric_expression int32) → date

  • numeric_expression: A Unix epoch timestamp.

Examples

{% code title="TO_DATE example" %}

SELECT TO_DATE(1640131200)
-- 2021-12-22

{% endcode %}

TO_DATE(numeric_expression float) → date

  • numeric_expression: A Unix epoch timestamp.

Examples

{% code title="TO_DATE example" %}

SELECT TO_DATE(1665131223.69)
-- 2022-10-07

{% endcode %}

TO_DATE(numeric_expression int64) → date

  • numeric_expression: A Unix epoch timestamp.

Examples

{% code title="TO_DATE example" %}

SELECT TO_DATE(1640131200)
-- 2021-12-22

{% endcode %}

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

{% code title="TO_DATE example" %}

SELECT TO_DATE('2022-07-22.23', 'YYYY-MM-DD', 1)
-- NULL

{% endcode %}

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

{% code title="TO_DATE example" %}

SELECT TO_DATE('05/24/22', 'MM/DD/YY')
-- 2022-05-24

{% endcode %}

TO_DATE(numeric_expression double) → date

  • numeric_expression: A Unix epoch timestamp.

Examples

{% code title="TO_DATE example" %}

SELECT TO_DATE(1665131223.69)
-- 2022-10-07

{% endcode %}