MariaDB: TO_DAYS Function
This MariaDB tutorial explains how to use the MariaDB TO_DAYS function with syntax and examples.
Description
The MariaDB TO_DAYS function converts a date into numeric days.
Syntax
The syntax for the TO_DAYS function in MariaDB is:
TO_DAYS( date )
Parameters or Arguments
- date
- The date to convert to numeric days.
Note
- The TO_DAYS function is to be used only with dates within the Gregorian calendar.
- The TO_DAYS function will return NULL, if date is '0000-00-00'.
- See also the TO_DAYS function which is the reverse of the FROM_DAYS function.
Applies To
The TO_DAYS function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB TO_DAYS function examples and explore how to use the TO_DAYS function in MariaDB.
For example:
SELECT TO_DAYS('2014-11-16'); Result: 735918 SELECT TO_DAYS('14-11-16'); Result: 735918 SELECT TO_DAYS('2014-11-17'); Result: 735919 SELECT TO_DAYS('2014-11-18 05:30:00'); Result: 735920 SELECT TO_DAYS('0000-01-01'); Result: 1 SELECT TO_DAYS('0000-00-00'); Result: NULL
Advertisements