tryparseweek(source: text, format: text) 🡒 (boolean, number), pure function

Returns a (boolean, number) tuple. The first argument is the value to be parsed. The second argument is the time format. The returned Boolean flag is true if the value has been parsed. The returned number value is non-default only if the parsing succeeded.


table T = with
  [| as Id, as Raw, as Format    |]
  [| 1, "202103",   "vvvvww"     |]
  [| 2, "2021-S03", "vvvv-'S'ww" |]
  [| 3, "2021S-03", "vvvv'S'-ww" |]
  [| 4, "2021S03",  "vvvv'S'ww"  |]

T.Ok, T.Parsed = tryparseweek(T.Raw, T.Format) 

show table "Results" a1e4 with
  T.Parsed // 2021-W03

More on the format value:

Beware, the standard Gregorian calendar and teh ISO-8601 calendar are different.

User Contributed Notes
0 notes + add a note