THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL DATEDIFF() Function

❮ MySQL Functions

Example

Return the difference in days between two date values:

SELECT DATEDIFF("2017-06-25", "2017-06-15");
Try it Yourself »

Definition and Usage

The DATEDIFF() function returns the difference in days between two date values.

Syntax

DATEDIFF(date1, date2)

Parameter Values

Parameter Description
date1, date2 Required. The two dates to calculate the difference between. (date1 - date2)

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1

More Examples

Example

Return the difference in days between two date values:

SELECT DATEDIFF("2017-06-25 09:34:21", "2017-06-15 15:25:35");
Try it Yourself »

Example

Return the difference in days between two date values:

SELECT DATEDIFF("2017-01-01", "2016-12-24");
Try it Yourself »

❮ MySQL Functions