> ## Documentation Index
> Fetch the complete documentation index at: https://firebolt-aggregate-helm-docs-pr-97.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Date & time functions

> Snowflake date & time functions supported in Snowflake compatibility mode.

<span className="feature-tag">Preview</span>

Snowflake [date & time functions](https://docs.snowflake.com/en/sql-reference/functions-date-time) in [Snowflake compatibility mode](/reference-sql/snowflake/overview).

A date part can be written as a bare keyword, as `DATEADD(day, 1, d)`, or quoted, as `DATEADD('day', 1, d)`. Both are accepted, in every function that takes one.

Snowflake's [aliases](https://docs.snowflake.com/en/sql-reference/functions-date-time) are normalised to the full part name, so `YYYY`, `YR`, `MM`, `MONS`, `DD`, `WK`, `WOY`, `QTR`, `HRS`, `MINS` and `SECS` all work. Note that `M` is minute and `MM` is month, as in Snowflake. `EPOCH` and `EPOCH_SECOND` give seconds since the epoch.

Parts with no equivalent here are refused rather than approximated: `DAYOFWEEK`, `DAYOFYEAR`, the ISO parts, and the sub-second `EPOCH_*` parts. The last of those matters because the extractor available for them returns the milliseconds within the second rather than since the epoch, which is a different number.

| Function                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Support       | Notes                                                                       |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | :-------------------------------------------------------------------------- |
| [`DATEADD`](https://docs.snowflake.com/en/sql-reference/functions/dateadd), [`TIMEADD`](https://docs.snowflake.com/en/sql-reference/functions/timeadd), [`TIMESTAMPADD`](https://docs.snowflake.com/en/sql-reference/functions/timestampadd)                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Supported     | Adding to a `DATE` returns a `TIMESTAMP`, where Snowflake returns a `DATE`. |
| [`DATEDIFF`](https://docs.snowflake.com/en/sql-reference/functions/datediff), [`TIMEDIFF`](https://docs.snowflake.com/en/sql-reference/functions/timediff), [`TIMESTAMPDIFF`](https://docs.snowflake.com/en/sql-reference/functions/timestampdiff)                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Supported     |                                                                             |
| [`DATE_PART`](https://docs.snowflake.com/en/sql-reference/functions/date_part)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Supported     | The part must be a literal, since it selects the function to call.          |
| [`DATE_TRUNC`](https://docs.snowflake.com/en/sql-reference/functions/date_trunc)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Supported     |                                                                             |
| [`YEAR`](https://docs.snowflake.com/en/sql-reference/functions/year), [`MONTH`](https://docs.snowflake.com/en/sql-reference/functions/year), [`DAY`](https://docs.snowflake.com/en/sql-reference/functions/year), [`HOUR`](https://docs.snowflake.com/en/sql-reference/functions/hour-minute-second), [`MINUTE`](https://docs.snowflake.com/en/sql-reference/functions/hour-minute-second), [`SECOND`](https://docs.snowflake.com/en/sql-reference/functions/hour-minute-second), [`QUARTER`](https://docs.snowflake.com/en/sql-reference/functions/year), [`WEEK`](https://docs.snowflake.com/en/sql-reference/functions/year), [`WEEKOFYEAR`](https://docs.snowflake.com/en/sql-reference/functions/year) | Supported     |                                                                             |
| [`TO_DATE`](https://docs.snowflake.com/en/sql-reference/functions/to_date), [`TO_TIMESTAMP`](https://docs.snowflake.com/en/sql-reference/functions/to_timestamp)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Supported     |                                                                             |
| [`CURRENT_DATE`](https://docs.snowflake.com/en/sql-reference/functions/current_date)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Supported     | Both the bare keyword and the called form.                                  |
| [`LAST_DAY`](https://docs.snowflake.com/en/sql-reference/functions/last_day), [`NEXT_DAY`](https://docs.snowflake.com/en/sql-reference/functions/next_day), [`PREVIOUS_DAY`](https://docs.snowflake.com/en/sql-reference/functions/previous_day), [`ADD_MONTHS`](https://docs.snowflake.com/en/sql-reference/functions/add_months), [`MONTHS_BETWEEN`](https://docs.snowflake.com/en/sql-reference/functions/months_between)                                                                                                                                                                                                                                                                                | Not supported |                                                                             |
| [`CONVERT_TIMEZONE`](https://docs.snowflake.com/en/sql-reference/functions/convert_timezone)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Not supported |                                                                             |
| `DATEFROMPARTS`, `DATE_FROM_PARTS`, `TIMEFROMPARTS`, `TIME_FROM_PARTS`, `TIMESTAMPLTZFROMPARTS`, `TIMESTAMPTZFROMPARTS`, `TIMESTAMP_LTZ_FROM_PARTS`, `TIMESTAMP_TZ_FROM_PARTS`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Not supported |                                                                             |
| [`DAYNAME`](https://docs.snowflake.com/en/sql-reference/functions/dayname), [`MONTHNAME`](https://docs.snowflake.com/en/sql-reference/functions/monthname)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Not supported |                                                                             |
| [`DAYOFWEEK`](https://docs.snowflake.com/en/sql-reference/functions/year), [`DAYOFYEAR`](https://docs.snowflake.com/en/sql-reference/functions/year), [`YEAROFWEEK`](https://docs.snowflake.com/en/sql-reference/functions/year)                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Not supported |                                                                             |

## Limitations

`DATEADD` on a `DATE` returns a `TIMESTAMP` at midnight rather than a `DATE`. The instant is the same; a client that checks the column type sees a different one. Confirmed against Snowflake: `DATEADD(day, 1, DATE '2024-03-15')` is typed `DATE` there and `TIMESTAMP` here.

A part Firebolt does not carry, such as `nanoseconds`, is named in the error rather than silently dropped.
