---
title: next_day function
description: Learn the syntax of the next\_day function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/next_day
---

# `next_day` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the first date which is later than `expr` and named as in `dayOfWeek`.

## Syntax

```
next_day(expr, dayOfWeek)
```

## Arguments

* `expr`: A DATE expression.
* `dayOfWeek`: A STRING expression identifying a day of the week.

## Returns

A DATE.

dayOfWeek must be one of the following (case insensitive):

* `'SU'`, `'SUN'`, `'SUNDAY'`
* `'MO'`, `'MON'`, `'MONDAY'`
* `'TU'`, `'TUE'`, `'TUESDAY'`
* `'WE'`, `'WED'`, `'WEDNESDAY'`
* `'TH'`, `'THU'`, `'THURSDAY'`
* `'FR'`, `'FRI'`, `'FRIDAY'`
* `'SA'`, `'SAT'`, `'SATURDAY'`

If `dayOfWeek` is not a recognized day name, Databricks raises [INVALID\_PARAMETER\_VALUE](https://docs.databricks.com/aws/en/error-messages/invalid-parameter-value-error-class.md).

> [!NOTE]
>
> In Databricks Runtime, if [spark.sql.ansi.enabled](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-ansi-compliance.md) is `false`, the function returns `NULL` instead of an error for a malformed `dayOfWeek`.

## Common error conditions

* [INVALID\_PARAMETER\_VALUE](https://docs.databricks.com/aws/en/error-messages/invalid-parameter-value-error-class.md)

## Examples

```sql
> SELECT next_day('2015-01-14', 'TU');
 2015-01-20

> SELECT next_day('2024-01-01', 'INVALID');
  Error: INVALID_PARAMETER_VALUE
```

## Related functions

* [`dayofweek` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/dayofweek.md)
* [`last_day` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/last_day.md)
