How i can constrain a datefield to be today or 5 days max before?

1035
6
Jump to solution
06-12-2017 08:03 AM
LouisDECOMBE
Occasional Contributor

hi, 

Is there someone to help me on constraint with date field.

I've a datefield and i want that the user put a date that would be the d-day or 5 days before the d-day max.

I've tried with : >now() +5*24*60*60*1000, but does not function.

Thank you for your help.

A french guy!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Louis,

So the valid dates are from today -5 days?  In that case you would need a compound statement to set lower and upper bounds:

int(.) >= int(today()) - 5*24*60*60*1000 and int(.) <= today(.)

So it must be greater than or equal to 5 days ago and less than or equal to today.

View solution in original post

6 Replies
IsmaelChivite
Esri Notable Contributor

Bon jour Louis.  Attaching an example that worked  for me.

LouisDECOMBE
Occasional Contributor

Hi Ismael, 

Thank you for your help. I've tried but still does not function

see in the attached video: https://framadrop.org/r/EtNaumkzlh#FgGTNJK0byjyhHCA4dmY7rWSZVYSq28AGj7emVtR+vQ=

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Louis,

There seems to be a type conversion issue causing the problem.  can you try the following constraint:

int(.) < int(today()) + 5*24*60*60*1000

The addition should work correctly with everything being an integer.

LouisDECOMBE
Occasional Contributor

Hi James, 

Thank you for your answer. I would never find it alone !

It seems to work. But what i wanted to do was to forbidden a date after today and more than 5 days before today

For exemple, we are the 15/06/2017

The user can had 10/06 , 11/06, 12/06, 13/06, 14/06 and 15/06 but not more.

What would be the constrain for that?

Regards

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Louis,

So the valid dates are from today -5 days?  In that case you would need a compound statement to set lower and upper bounds:

int(.) >= int(today()) - 5*24*60*60*1000 and int(.) <= today(.)

So it must be greater than or equal to 5 days ago and less than or equal to today.

LouisDECOMBE
Occasional Contributor

PERFECT

THANK YOU VERY MUCH!

It works great

0 Kudos