This article looks at the difference between two MySQL functions; DATEDIFF()
and TIMESTAMPDIFF()
.
Both functions return the difference between two dates and/or times, but the result is different between the two functions.
The following table summarizes the difference between these two functions:
DATEDIFF() |
TIMESTAMPDIFF() |
---|---|
Requires 2 arguments. | Requires 3 arguments. |
Subtracts the 2nd argument from the 1st (expr1 − expr2). | Subtracts the 2nd argument from the 3rd (expr2 − expr1). |
Result is expressed as a value in days. | Result is expressed as the unit provided by the first argument. |
Can compare only the date value of its arguments. | Can compare the date and time value of its arguments. |