NthWeekdayFromDate function

Returns the date of the specified day of the week offset by the specified number of weeks from the source date. The day of the week is specified as the full name, for example, thursday, or a three-letter abbreviation, for example, thu. The offset values can be positive, negative, or zero.

Namespace

datetime

Input

base date(date|string), day of the week(string), week offset(int)

Output

date(date)

Example

If basedate contains the date 2009-08-18 and Thursday is specified with an offset of 1, then the two following functions are equivalent, and return the value 2009–08–20:

set-column result datetime:NthWeekdayFromDate('2009-08-18', 'thursday', 1) set-column result datetime:NthWeekdayFromDate(basedate, 'thu', 1)

The first occurrence of Thursday is returned. In the proceeding example, the Thursday occurs in the same week as the date 2009-08-18. The date 2009-08-18 is a Tuesday. If basedate contains the date 2009-08-18 and Thursday is specified with an offset of -2, then the two following functions are equivalent, and return the value 2009–08–06:

set-column result datetime:NthWeekdayFromDate('2009-08-18', 'thursday', -2) set-column result datetime:NthWeekdayFromDate(basedate, 'thu', -2)

 

Created in 2020 by Google Inc.