Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

TO_DAYS

Example

Return the number of days since year 0 for a given date or datetime value.

SELECT TO_DAYS(“2017-06-20”);

Definition and Usage

The TO_DAYS() function calculates the number of days between a date and year 0 (date “0000-00-00”) within the Gregorian calendar.

Note: This function performs the inverse operation of the FROM_DAYS() function.

Syntax

TO_DAYS(date)

Parameter Values

Parameter

Description

date

Required: The specified date

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Calculate the number of days from year 0 to the given date.

SELECT TO_DAYS(“2017-06-20 09:34:00”);