DATEDIFF
Compares two dates or timestamps and returns the difference in days.
Syntax
DATEDIFF(endDate string, startDate string) → integer
endDate: A
DATE
orTIMESTAMP
expression.startDate: A
DATE
orTIMESTAMP
expression.
Examples
SELECT DATEDIFF('2021-02-28', '2021-01-01')
-- 58
SELECT DATEDIFF('2005-04-09 12:05:55', '2003-02-01 11:43:22')
-- 798
Usage Notes
If endDate
is before startDate
the result is negative.
Last updated
Was this helpful?