Date validation: what am I doing wrong?

6
Object has attribute Birthdate. This has a validation rule (range) >= 01-01-1910 and <= 31-12-1994. I enter a date 11-08-1967. This gives the error message I specified for that validation ("date should be between 1910 en 1994"). Obviously it is.
asked
4 answers
5

Hi Kees,

A better idea is using a microflow to check the validation. By using microflow, you don't have to use 'hard coded' date ranges.

For example:

Your validation rule could be: The birthday should be between (CurrentDateTime - 18 years) and (CurrentDateTime - 110 years). Then you can check whether the input date is between the predefined range or not. If not, end your microflow by showing a validation message.

The microflow expression can be:

$Object/Date <= addYears([%CurrentDateTime%],-18) and $Object/Date >= addYears([%CurrentDateTime%],-110)

Still, you can make a test project and add a bug report of your date range validation issue on meta object level to our Partner Portal.

answered
4

Try using slashes rather than dashes. i.e. (range) >= 01/01/1910 and <= 31/12/1994.

answered
3

Hi Fedor,

Your answer isn't fully right, as I could see even without testing it. You give the code as:

$Object/Date <= addDays([%CurrentDateTime%],-18) and [%CurrentDateTime%] >= addDays([%CurrentDateTime%],-110)

It should be: $Object/Date <= addYears([%CurrentDateTime%],-18) and $Object/Date >= addYears([%CurrentDateTime%],-110)

As it is, it only checks less than 18 days ago.

answered
2

I think this is caused because the date '01-01-1910' isn't properly recognized as a datetime format.

Try comparing it to this:

dateTime(1910, 1, 1) and dateTime(1994, 12, 31)

Check Microflow expressions for more information about the dateTime expression.

answered