MySQL TIMEDIFF() Function

MySQL | TIMEDIFF() Function: Learn about the TIMEDIFF() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 12, 2022

TIMEDIFF() Function

Whenever you want to find out the difference between two time periods then the TIMEDIFF() function is used. This function gives you the exact time difference between two time periods.

TIMEDIFF() Syntax

SELECT TIMEDIFF(time1, time2);

TIMEDIFF() Parameter(s)

For this function, it is important to give two times as a parameter. You can also provide datetime values as a parameter.

TIMEDIFF() Return Value

This function will return the time after calculating the difference between the two time periods which you have provided.

MySQL TIMEDIFF() Function Example 1

SELECT TIMEDIFF("10:10:10", "12:12:12");
Example 1: MySQL TIMEDIFF() Function

MySQL TIMEDIFF() Function Example 2

SELECT TIMEDIFF("15:11:11", "10:12:12.0009");
Example 2: MySQL TIMEDIFF() Function

MySQL TIMEDIFF() Function Example 3

SELECT TIMEDIFF("16:12:10.00008", "10:12:12.0009");
Example 3: MySQL TIMEDIFF() Function


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.