Skip to content

daft.functions.next_day#

next_day #

next_day(expr: Expression, day_of_week: str) -> Expression

Returns the next occurrence of the specified day of the week after the given date.

Parameters:

Name Type Description Default
expr Expression

a Date or Timestamp expression.

required
day_of_week str

the target weekday (e.g. "Monday", "Mon").

required

Returns:

Name Type Description
Expression Expression

a Date expression for the next occurrence of that weekday.

Examples:

1
2
3
>>> import daft
>>> from daft.functions import next_day
>>> next_day(daft.col("dt"), "Monday")
next_day(col(dt), lit("Monday"))
Source code in daft/functions/datetime.py
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
def next_day(expr: Expression, day_of_week: str) -> Expression:
    """Returns the next occurrence of the specified day of the week after the given date.

    Args:
        expr: a Date or Timestamp expression.
        day_of_week: the target weekday (e.g. ``"Monday"``, ``"Mon"``).

    Returns:
        Expression: a Date expression for the next occurrence of that weekday.

    Examples:
        >>> import daft
        >>> from daft.functions import next_day
        >>> next_day(daft.col("dt"), "Monday")
        next_day(col(dt), lit("Monday"))
    """
    expr = Expression._to_expression(expr)
    return Expression._call_builtin_scalar_fn("next_day", expr, day_of_week=day_of_week)