def pure tryParseWeek(source: text, format: text): (boolean, week)
def pure tryParseWeek(source: text; format: text): (boolean, week)
Parses source as an ISO week using format and returns a success flag and a
week value. When parsing fails, the week defaults to 2001-W01.
Example
table T = with
[| as Raw |]
[| "2021-W03" |]
[| "202103" |]
[| "bad" |]
T.Ok, T.Parsed = tryParseWeek(T.Raw; "vvvv-'W'ww")
show table "Parsed weeks" with
T.Raw
T.Ok
T.Parsed
This outputs the following table:
Raw
Ok
Parsed
2021-W03
true
2021-W03
202103
false
2001-W01
bad
false
2001-W01
Format specification
Supported format tokens are vv, vvvv, w, and ww. Alphabetic characters
must be quoted with single quotes.