Jump to: navigation, search

Mysql DATEDIFF

From w3cyberlearnings

Contents

MySQL DATEDIFF Function

This function returns the date different between two days.

Syntax DATEDIFF

  • expre1: date or timestamp expression input 1
  • expre2: date or timestamp expression input 2
DATEDIFF(expre1, expre2);

Example 1

mysql> SELECT DATEDIFF('2012-12-01','2012-11-01');
+-------------------------------------+
| DATEDIFF('2012-12-01','2012-11-01') |
+-------------------------------------+
|                                  30 |
+-------------------------------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT DATEDIFF('2012-12-01 10:30:40','2012-11-01 9:30:40');
+------------------------------------------------------+
| DATEDIFF('2012-12-01 10:30:40','2012-11-01 9:30:40') |
+------------------------------------------------------+
|                                                   30 |
+------------------------------------------------------+
1 row in set (0.00 sec)

Related Links



Navigation
Web
SQL
MISC
References