Skip to content

TO_DAYS

  • date: This parameter represents the date for which the number of days up to the date will be returned. It must be a value that can be interpreted as a date such as a ‘YYYY-MM-DD’ or ‘YY-MM-DD’ formatted string, a ‘DD-MM-YYYY’ or ‘DD-MM-YY’ formatted string, a DATE, a DATETIME, or a TIMESTAMP. Incorrectly formatted dates or those outside of the valid range (‘1000-01-01’ to ‘9999-12-31’) return NULL.
SELECT TO_DAYS('2018-06-15');
737226

The TO_DAYS() function in MySQL is used to get the number of days between the given date and zero date (0 AD). In the provided example, TO_DAYS() function is used to return the number of days between ‘2018-06-15’ and zero date. The output is 737226, indicating that there are 737226 days between ‘2018-06-15’ and 0 AD.