How would I validate a string in the format YYYYMMDD is a valid date? I assume the range of valid years is 1940 to 2050.
Validate a string in the format YYYYMMDD
Best answer by may_kwok
Pasting the screenshot here for easier viewing:

The substr expression in Ataccama takes the first digit as position 0.

So, if you have string = ‘20250130’, your expression substr(field_4,1,4) will evaluate to ‘20250130’ instead of ‘20250130’.
If you wanted the first 4 chars and you wanted to use the substr expression, then it needs to be substr(field_4,0,4).
If you wanted to allow nulls, you can edit the rule so that:
Condition 1 is that if it is empty, it is valid (instead of invalid). Then,
Condition 2 is make sure the string can convert to a date. Then,
Condition 3 is the year is within range.
Then you can avoid all the logic like “month cannot be greater than 12”, 28 / 29 / 31 days, which can just be validated against the calendar.
Does this help?
Reply
Login to the Ataccama Community
No account yet? Create an account
For Ataccama Customers and Partners
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.