SQL DATEDIFF()

SQL  DATEDIFF() function returns the time between two dates.

Table – orders

+—–+—–+——-+———————+———————+
| oid | uid | items | date                | delivery_date       |
+—–+—–+——-+———————+———————+
|   1 |   1 | AAAA  | 2007-05-16 00:00:00 | 2007-05-24 00:00:00 |
+—–+—–+——-+———————+———————+

Example

mysql> SELECT DATEDIFF(delivery_date,date) AS days FROM orders;
+——+
| days |
+——+
|    8 |
+——+
1 row in set (0.03 sec)