bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL DATEDIFF() Function

Concept visual

MySQL DATEDIFF() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Return the number of days between two date values:

SELECT DATEDIFF("2017-06-25", "2017-06-15");

Definition and Usage

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

Syntax

Datediff(

date1, date2 )

Parameter Values

Parameter

Description date1, date2 Required. Two dates to calculate the number of days between. (date1 - date2)

Technical Details

Works in:

From MySQL 4.0

More Examples

Example

Return the number of days between two date values: SELECT DATEDIFF("2017-06-25 09:34:21", "2017-06-15 15:25:35");

Example

Return the number of days between two date values:

SELECT DATEDIFF("2017-01-01",
"2016-12-24");

Previous

❮ MySQL Functions

Next

Previous

MySQL DATE() Function

Next

MySQL DATE_ADD() Function