MySQL TO_DAYS() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL TO_DAYS() Function

❮ MySQL Functions

Example

Convert a date into numeric days:

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

Definition and Usage

The TO_DAYS() function converts a date into numeric days.

The TO_DAYS() function is to 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 date to convert to a numeric day. If date is "0000-00-00", TO_DAYS() will return NULL

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

Convert a date into numeric days:

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

❮ MySQL Functions