Categories: Date/Time
TIMESTAMPDIFF
Return the amount of time between two date or timestamp values
Syntax
TIMESTAMPDIFF(unit symbol, giventime1 date or timestamp, givenTime2 date or timestamp) → INTEGER
- unit: The unit of the interval. Must be one of the following: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND.
- giventime1: The first date or timestamp (subtrahend)
- givenTime2: The second date or timestamp (minuend)
Examples
TIMESTAMPDIFF exampleSELECT timestampdiff(month, date '2021-02-01', date '2021-05-01');
-- 3
SELECT timestampdiff(day, timestamp '2003-02-01 11:43:22', timestamp '2005-04-09 12:05:55');
-- 798
Was this page helpful?
Glad to hear it! Thank you for your feedback.
Sorry to hear that. Thank you for your feedback.