Skip to main content
Returns the date of the first specified day of week (DOW) that occurs before the input date (DATE or DATETIME). For example, previous_day('2023-04-06', 'Monday') returns the date of the previous Monday that occurred before ‘2023-04-06’. This function is supported from v3.1. It is the opposite of next_day.

Syntax

Parameters

  • date_expr: the input date. It must be a valid DATE or DATETIME expression.
  • dow: the day of week. Valid values include a number of abbreviations which are case-sensitive:

Return value

Returns a DATE value. Any invalid dow will cause an error. dow is case-sensitive. NULL is returned if an invalid date or a NULL argument is passed in.

Examples

keyword

PREVIOUS_DAY, PREVIOUS, previousday