weekNum

weekNum, function

def const pure weekNum(d: date): number
def const pure weekNum(w: week): number

Returns the ISO week number (1-53) of the provided date or week.

Example (date input)

table T = with
  [| as Label, as D |]
  [| "2019-12-28", date(2019, 12, 28) |]
  [| "2019-12-31", date(2019, 12, 31) |]
  [| "2020-01-01", date(2020, 1, 1) |]

show table "Week numbers" with
  T.Label
  weekNum(T.D) as "WeekNum"

This outputs the following table:

Label WeekNum
2019-12-28 52
2019-12-31 1
2020-01-01 1

Example (week input)

table W = with
  [| as Label, as W |]
  [| "2019-W05", week(2019, 5) |]
  [| "2019-W52", week(2019, 52) |]
  [| "2020-W01", week(2020, 1) |]

show table "Week numbers" with
  W.Label
  weekNum(W.W) as "WeekNum"

This outputs the following table:

Label WeekNum
2019-W05 5
2019-W52 52
2020-W01 1

See also

User Contributed Notes
0 notes + add a note