TO_DAYS Function

Description

The TO_DAYS function returns the number of days after year 0 in the rage of 366 to 3652424 from specified argument. You can specify DATE type; the value is returned in INTEGER type.

It is not recommended to use the TO_DAYS function for dates prior to the year 1582, as the function does not take dates prior to the introduction of the Gregorian Calendar into account.

Syntax

TO_DAYS(date)

Example

SELECT TO_DAYS('2010-10-04');

   to_days('2010-10-04')

========================

                  734414

 

SELECT TO_DAYS('2010-10-04 12:34:56');

   to_days('2010-10-04 12:34:56')

================================

                          734414

 

SELECT TO_DAYS('2010-10-04 12:34:56.7890');

   to_days('2010-10-04 12:34:56.7890')

======================================

                                734414

 

SELECT TO_DAYS('1-1-1');

   to_days('1-1-1')

===================

                366

 

SELECT TO_DAYS('9999-12-31');

   to_days('9999-12-31')

========================

                 3652424

 

SELECT TO_DAYS ('12:34:56');

 

ERROR: Conversion error in date format.