weekBegin#

swordfish.function.weekBegin()#

For each element of X, return the first date of the week that it belongs to and that starts on the day as specified by parameter weekday.

  • If parameter weekday>weekday(X, false): for each element of X, return a date that corresponds to the specified weekday parameter in the previous calendar week.

  • If parameter weekday<=weekday(X, false): for each element of X, return a date that corresponds to the specified weekday parameter in the same calendar week.

If parameter offset is specified, the result is updated every n weeks. Please refer to example 2 below. The parameters offset and n must be specified together, and offset takes effect only when n > 1.

Parameters:
  • X (Constant) – A scalar/vector of type DATE, DATETIME, DATEHOUR, TIMESTAMP or NANOTIMESTAMP.

  • weekday (Constant, optional) – An integer from 0 to 6. 0 means Monday, 1 means Tuesday, …, and 6 means Sunday, by default DFLT.

  • offset (Constant, optional) – A scalar of the same data type as X. It must be no greater than the minimum value of X, by default DFLT.

  • n (Constant, optional) – A positive integer, by default DFLT