Constraint on date field not working

266
3
08-04-2021 09:27 AM
abureaux
Occasional Contributor III

Hello,

I have an issue with a constraint on a date field...

This is an incident form, and I cannot have users select a date > today. I also don't want users lying about the date. As such, I set the constraint up as follows:

TypeNameCalculationConstraint
Calculatetoday_date_calformat-date(today(),'%d-%m-%Y') 
dateTimeactual_date ${actual_date_cal}<=${today_date_cal}
Calculateactual_date_calformat-date(${actual_date},'%d-%m-%Y') 

Obviously, I am trying to strip away the H/m/s component and just compare dates.

 

Future date = Constraint ACTIVE. Great!

Today = Constraint INACTIVE. Great!

Earlier this month = Constraint INACTIVE. Great!

Anything before this month (e.g., last month) = Constraint ACTIVE. Wut?

 

So, I am probably missing something very obvious, but I am not sure what that is right now. Any insight?

Thank you.

0 Kudos
3 Replies
DougBrowning
MVP Notable Contributor

I think format date may turn it into a string causing a string compare.  Try comparing the actual date field instead.  Just a guess.

0 Kudos
abureaux
Occasional Contributor III

Thanks for the response.

After some [odd] tests, I think you may be correct. That complicates things since I need to report time as well, and that is known to cause problems with constraints.

Knowing this, I'll do some more testing and see if I can figure out something reasonable.

0 Kudos
DougBrowning
MVP Notable Contributor

Just do both.  Have one field for the check and one to store.  You can set Esri bind to null and it wont upload to the service.

Of course this may cause issue when you want to compare dates in the future.  I usually store it as time then format it when you need it like in the map or report.

0 Kudos