> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_days.md).

# TO\_DAYS

## Syntax

```bnf
TO_DAYS(date)
```

## Description

Given a date `date`, returns the number of days since the start of the current calendar (`0000-00-00`).

The function is not designed for use with dates before the advent of the Gregorian calendar in October 1582. Results are not reliable since it doesn't account for the lost days when the calendar changed from the Julian calendar.

This is the converse of the [FROM\_DAYS()](/docs/server/reference/sql-functions/date-time-functions/from_days.md) function.

## Examples

```sql
SELECT TO_DAYS('2007-10-07');
+-----------------------+
| TO_DAYS('2007-10-07') |
+-----------------------+
|                733321 |
+-----------------------+

SELECT TO_DAYS('0000-01-01');
+-----------------------+
| TO_DAYS('0000-01-01') |
+-----------------------+
|                     1 |
+-----------------------+

SELECT TO_DAYS(950501);
+-----------------+
| TO_DAYS(950501) |
+-----------------+
|          728779 |
+-----------------+
```

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
