Jump to: navigation, search

Mysql TIMEDIFF

From w3cyberlearnings

Contents

MySQL TIMEDIFF Function

This function returns a different of two time.

Syntax TIMEDIFF

  • input1: time or datetime string
  • input2: time or datetime string
TIMEDIFF(input1, input2);

Example 1

mysql> SELECT TIMEDIFF('2012-04-02 10:04:43','2012-04-02 8:03:40');
+------------------------------------------------------+
| TIMEDIFF('2012-04-02 10:04:43','2012-04-02 8:03:40') |
+------------------------------------------------------+
| 02:01:03                                             |
+------------------------------------------------------+
1 row in set (0.00 sec)

Example 2


mysql> SELECT TIMEDIFF('2012-04-02 10:04:43','2012-03-1 8:03:40');
+-----------------------------------------------------+
| TIMEDIFF('2012-04-02 10:04:43','2012-03-1 8:03:40') |
+-----------------------------------------------------+
| 770:01:03                                           |
+-----------------------------------------------------+
1 row in set (0.00 sec)


Related Links



Navigation
Web
SQL
MISC
References