Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
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”);