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
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
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)