tryparsedate(source: text, format: text) 🡒 (boolean, date), pure function

The first argument is the value to be parsed.

The second argument is the date format, as documented in function format().

Returns a (boolean,date) tuple. The returned boolean flag is true if and only if the value has been parsed. The returned date value is valid only if the parsing succeeded, its value is unspecified if the parsing failed.

table T = with 
  [| "2022-10-18" as text |]
  [| "10/18/2022" |] // <- invalid format
  [| "1990-01-01" |] // <- valid format but out of bounds
  [| "2011-05-07"  |]

T.ok, T.d = tryparsedate(T.text, "yyyy-MM-dd")
where T.ok
  show table "Parsed" with 

See also