THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL TO_DAYS() Function

❮ MySQL Functions

Example

Return the number of days between the date and year 0:

SELECT TO_DAYS("2017-06-20");
Try it Yourself »

Definition and Usage

The TO_DAYS() function returns the number of days between a date and date "0000-00-00" (year 0).

The TO_DAYS() function can be used only with dates within the Gregorian calendar.

Note: The TO_DAYS() function is the reverse of the FROM_DAYS() function.

Syntax

TO_DAYS(date)

Parameter Values

Parameter Description
date Required. The given date

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Return the number of days between the date and year 0:

SELECT TO_DAYS("2017-06-20 09:34:00");
Try it Yourself »

❮ MySQL Functions