Hello,
I am trying to restrict a date range based on a previously entered date. Here's the goal:
Question 1: Enter a date at least seven days from today.
Question 2: Enter a date less than two months (62 days) from the date entered in Q1.
The setup: Survey123 Connect, survey published to Enterprise Portal 10.8.1
Constraints:
Q1: .>date(decimal-date-time(now()) + 7)
Q2: (.>=${Q1}) and (.<=(${Q1} + (1000 * 60 * 60 * 24 * 62)))
When published, Q1 works fine, but no date entered into Q2 is accepted by the form (no errors when saving .xls form or publishing).
Solved! Go to Solution.
Are you trying to constrain from today until 14 days from now? That is what is looks like. If so this works for me
${testdate} >= now() and ${testdate} <= date(decimal-date-time(now()) + 14)
Hope that does it
Try changing all your . to ${Q2} sometimes .<= or others gets confused with HTML and causes issues. Esp in the web form. Being specific vs just the . can help.
So ({Q2}>=${Q1}) and ({Q2}<=(${Q1} + (1000 * 60 * 60 * 24 * 62))) ?
That gives me an error converting XLSForm
you forgot the $
Ugh forgive me that oversight. Still getting the same problem in the form though.
So is it just not getting stopped for blank for Q2? you can make Q2 required or add to the constraint ${Q2} != ''
I think the calc is not firing when the field in blank.
Hm, so it is a required question. I also tried setting a default entry of today() thinking maybe you're right with the last comment there but that didn't do anything either. Where in the constraint would I add ${Q2} != ''? Would that have much a different function than setting a default entry?
Additionally, I tried using this constraint: (.>= today()) and (.<=(today() + (1000 * 60 * 60 * 24 * 14))), since ESRI documentation spells it out specifically. That actually gives the same problem in the form (again, no error when updating the xls form). No date is accepted.
Are you trying to constrain from today until 14 days from now? That is what is looks like. If so this works for me
${testdate} >= now() and ${testdate} <= date(decimal-date-time(now()) + 14)
Hope that does it
No, I was just trying to see if I could get anything to work in the constraint for Q2.
However, your example actually works, which is interesting. I wonder why it needs to be decimal time? So ultimately my successful constraint is:
${Q2} >= ${Q1} and ${Q2} <= date(decimal-date-time(${Q1}) + 62)
Dates are a different data type so you cannot just do math on them. Just like a string - 2 makes no sense. I will admit I do not know the exacts here either I always open up the form I got it to work in and copy paste :).