Parses source according to format and returns a success flag and a date.
Time information is accepted but discarded. When parsing fails or the result
falls outside the supported date range, the success flag
is false and the date value defaults to date(2001, 1, 1).
Example
table T = with
[| as Text |]
[| "2022-10-18" |]
[| "10/18/2022" |]
[| "1990-01-01" |]
[| "2011-05-07" |]
T.Ok, T.D = tryParseDate(T.Text; "yyyy-MM-dd")
show table "Parsed dates" with
T.Text
T.Ok
T.D
This outputs the following table:
Text
Ok
D
2022-10-18
true
2022-10-18
10/18/2022
false
2001-01-01
1990-01-01
false
2001-01-01
2011-05-07
true
2011-05-07
Remarks
Use the success flag instead of relying on the default date. The accepted
format tokens are documented in date and time format.