MySQL TIMEDIFF() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL TIMEDIFF() Function

❮ MySQL Functions

Example

Return the difference between two time values (expressed as a time value):

SELECT TIMEDIFF("13:10:11", "13:10:10");
Try it Yourself »

Definition and Usage

The TIMEDIFF() function returns the difference (expressed as a time value) between two time/datetime values.

Note: A time value can range from "-838:59:59" to "838:59:59".

Syntax

TIMEDIFF(time1, time2)

Parameter Values

Parameter Description
time1, time2 Required. The two times/datetimes to calculate the difference between. (time1 - time2)

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1

More Examples

Example

Return the difference between two datetime values (expressed as a time value):

SELECT TIMEDIFF("2017-06-25 13:10:11", "2017-06-15 13:10:10");
Try it Yourself »

❮ MySQL Functions