description |
---|
Compares two dates or timestamps and returns the difference in days. |
- endDate: A
DATE
orTIMESTAMP
expression. - startDate: A
DATE
orTIMESTAMP
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 %}
If endDate
is before startDate
the result is negative.