Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

DATEDIFF

Example

Calculate the number of days between two date values.

SELECT DATEDIFF(“2017-06-25”“2017-06-15”);

Definition and Usage

The DATEDIFF() function calculates the number of days between two date values.

Syntax

DATEDIFF(date1date2)

Parameter Values

Parameter

Description

date1, date2

Two dates are needed to calculate the difference in days between them: (date1 – date2).

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Provide the count of days between two date values.

SELECT DATEDIFF(“2017-06-25 09:34:21”“2017-06-15 15:25:35”);

Example

Calculate the number of days between two date values.

SELECT DATEDIFF(“2017-01-01”“2016-12-24”);