This article looks at the difference between the MySQL TIMEDIFF()
and TIMESTAMPDIFF()
functions.
Both functions do a similar thing, but there are some significant differences between the two.
The following table summarizes the difference between these two functions:
TIMEDIFF() |
TIMESTAMPDIFF() |
---|---|
Requires 2 arguments. | Requires 3 arguments. |
Subtracts the 2nd argument from the 1st (date1 − date2). | Subtracts the 2nd argument from the 3rd (date2 − date1). |
Result is expressed as a time value (and it has the limitations of the time data type). | Result is an integer, expressed by a number of units as provided by the first argument. |
Accepts time or datetime expressions. | Accepts date or datetime expressions. |
Both arguments must be the same type (either time or datetime). | Both arguments can be of a different type (date or datetime). |