Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

TIMEDIFF

Example

TIMEDIFF returns the difference between two time expressions.

SELECT TIMEDIFF(“13:10:11”“13:10:10”);

Definition and Usage

The TIMEDIFF() function calculates the difference between two time or datetime expressions.

Note: time1 and time2 must be in the same format, and the calculation performed is time1 – time2.

Syntax

TIMEDIFF(time1time2)

Parameter Values

Parameter

Description

time1

Required: A time value

time2

Mandatory: A time value

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Calculate the difference between two datetime expressions.

SELECT TIMEDIFF(“2017-06-25 13:10:11”“2017-06-15 13:10:10”);