Skip to main content
November 20, 2025
Solved

Wonkiness in todate() and how to validate incoming dates

  • November 20, 2025
  • 5 replies
  • 0 views

I am getting some strange values from todate().

{
  todate("02/28/2025"),
  todate("02/29/2025"),
  todate("02/30/2025"),
  todate("02/31/2025"),
  todate("02/32/2025"),
  todate("06/31/2025"),
  todate("RR/28/B025")
}

It seems to try to auto-correct an invalid date to a valid date.  But it also seems to allow characters in the date which it evaluates somehow and comes up with wild dates as a result.

First Question:  What's going on with todate() that it results in off-the-wall values?

My scenarion is this.... I have a webApi that receives a json string which contains structured data that includes multiple date fields.  The webApi uses cast/fromjson to convert the json input string directly to a CDT that uses Date fields.  The CDT is passed to our expression rules that operate on the data.

For example...

CDT  (SH_Test)

Expression rule (faking the WebApi)

a!localVariables(
  local!inputString: "{ ""name"": ""Bob Smith"", ""birthDate"": ""GG/28/2025"", ""favoriteColor"": ""red-orange""}",
  local!cdt: cast('type!{urn:com:appian:types:SH}SH_Test', a!fromJson(local!inputString)),
  local!cdt
)

Output

So the first time my expression rule can analyze the value, it is already a wonky date.

In theory, I could maybe separate the fromJson and the cast to insert some sort of date validation on the intermediary dictionary created by fromJson.  That would be ugly and cumbersome given the number of dates I have but doable (i'll just have to ask for a raise).

But, how can the date string be properly validated?  Is there anything built-in that will check a string for a valid date?  One that will complain for "02/29/2025" (not a leap year) or "GG/28/2025" (text month)?

Thanks.

Best answer by stefanhelzle0001

What should happen if the date is not good? Throw an error which you cannot catch? I think that you will to have validate the values as long as you can. In your situation, this means the intermediary dictionary.

5 replies

stefanhelzle0001
November 20, 2025

What should happen if the date is not good? Throw an error which you cannot catch? I think that you will to have validate the values as long as you can. In your situation, this means the intermediary dictionary.

November 20, 2025

Is there anything built in for this or do I need to craft the rules from scratch?  Date rules aren't too hard.

Timestamp rules would be untenable.  How in the world would I validate leap seconds?   Good thing I don't need this.

stefanhelzle0001
November 20, 2025

I do not know of anything built in. Maybe there is a plugin. But even date is tricky with all the leap year logic.