## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> EXCEL_DAY[EXCEL_DAY]:::quoted
EXCEL_DAY --> End((END))
```
## Purpose
The `EXCEL_DAY` SQL function gets the number which in Excel represents the date/time.
The function covers the leap year bug of Excel as described on https://en.wikipedia.org/wiki/Leap_year_problem. The day number increments by 2 between February 28, 1900 and March 1, 1900, although 1900 is not a leap year.
Parameters:
- Date (`datetime`): date/time to calculate Excel day number for.
Returns: the number which in Excel represents the date, with 1 meaning January 1, 1900, as a `decimal`.
## Examples
The following example retrieves the Excel day of noon on January 1, 2026:
```sql
select excel_day(to_date('20260101120000', 'YYYYMMDDHH24MISS'))
-------------------
46023.5
```
The following example retrieves the Excel day of January 1, 1900:
```sql
select excel_day(to_date('19000101', 'YYYYMMDD'))
-------------------
1
```
The following example illustrates the Excel leap year bug:
```sql
select excel_day(to_date('19000301', 'YYYYMMDD'))
- excel_day(to_date('19000228', 'YYYYMMDD'))
excel_diff_days
, to_date('19000301', 'YYYYMMDD')
- to_date('19000228', 'YYYYMMDD')
sql_diff_days
-------------------
2 1
```