This tutorial explains how to use the MySQL TO_DAYS function with syntax and examples.
The MySQL TO_DAYS function converts a date into numeric days.
The syntax for the TO_DAYS function in MySQL is:
TO_DAYS( date )
The date to convert to numeric days.
The TO_DAYS function can be used in the following versions of MySQL:
Let's look at some MySQL TO_DAYS function examples and explore how to use the TO_DAYS function in MySQL.
For example:
mysql> SELECT TO_DAYS('2014-02-17');
Output: 735646
mysql> SELECT TO_DAYS('14-02-17');
Output: 735646
mysql> SELECT TO_DAYS('2014-02-18');
Output: 735647
mysql> SELECT TO_DAYS('2014-02-19 05:30:00');
Output: 735648
mysql> SELECT TO_DAYS('0000-01-01');
Output: 1
mysql> SELECT TO_DAYS('0000-00-00');
Output: NULL