Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 809 Bytes

File metadata and controls

32 lines (23 loc) · 809 Bytes
description
Compares two dates or timestamps and returns the difference in days.

DATEDIFF

Syntax

DATEDIFF(endDate string, startDate string) → integer

  • endDate: A DATE or TIMESTAMP expression.
  • startDate: A DATE or TIMESTAMP expression.

Examples

{% code title="DATEDIFF example" %}

SELECT DATEDIFF('2021-02-28', '2021-01-01')
-- 58

{% endcode %}

{% code title="DATEDIFF example" %}

SELECT DATEDIFF('2005-04-09 12:05:55', '2003-02-01 11:43:22')
-- 798

{% endcode %}

Usage Notes

If endDate is before startDate the result is negative.