Solved

Validating two Date/Time Controls

  • 27 January 2022
  • 1 reply
  • 507 views

Hello, I am running into an issue and after trying formula after formula, reading forum after forum... I still can't seem to figure it out. 

 

I have a Nintex form, and there are multiple date entry fields for each section of the form. The first pair is "Start Date" and "End Date" which uses date only. The other two pairs I have which appear about 6~9 times are "Start Date & Time" and "End Date & Time", as well as "Issue Date & Time" and "Return Date & Time". I have applied rules to each in attempt to prevent the Return/End dates from being before the Issue/Start dates. 

 

The controls that only use the Date and not the time work perfectly with...

When: GreaterThan(StartDate,EndDate)

Then: Invalidate

Validation Message: End date must be after start date

 

But when I try to do this with fields using date and time, the rule does not do anything at all even when the formula should be shooting out as true. 

I tried: 

  • GreaterThan(StartDateTime,EndDateTime)
  • LessThan(EndDateTime,StartDateTime)
  • Tried the above with "<" and ">" 
  • Tried using {self} in place of EndDateTime since that is where I am applying the rule
  • formatDate(EndDateTime,"yyyyMMddHHmm")<formatDate(StartDateTime,"yyyyMMddHHmm") 
  • dateDiffHours(formatDate(EndDateTime,"yyyyMMddHHmm"),formatDate(StartDateTime,"yyyyMMddHHmm") 
  • Tried saying dateDiffHours must be >0 (when end, start) <0 with other way around
  • Tried having a separate calculated field to output string value and reference it from rule

 

I've tried other things but I just don't remember exactly what I else I tried off the top of my head. I've read in several places that the Time portion of he Date/Time control can be odd as it defaults to 00:00 and doesn't refresh instantly. If anyone knows what I can do to resolve this issue and get this rule working, I would greatly appreciate it! Pleas let me know if there is any other information I can provide to help answer this question. Thank you very much for your time in advance (:

 

icon

Best answer by Mjks_321 1 February 2022, 21:40

View original

1 reply

So, when I had come back to read this question I posted, it suddenly hit me... I have multiple panels with the same "Start Date/Time" , "End Date/Time" controls ALL with the same name!! I was using one rule and applying it to the different controls. The only reason it was working with the Start/End Date-only field was because that was the only one of them.


So, I went in to the form and tailored each Start/End Date&Time Control pair to have a specific name (e.i. StartDateTime1 EndDateTime1, StartDateTime2 EndDateTime2 ... etc.) and applied the basic validation rule:


When: EndDateTimeXYZ<StartDateTimeXYZ


Then: Invalidate 


Message: End Date cannot be before start date. 


 


And behold, all validation rules worked like a charm. 


One thing I did notice though, if the End Date is filled in before the Start Date and is an earlier day than the start date, sometimes the Error message doesn't show up, and to fix it the start date needs to be  entered first as well. 


 


Anyhow, most functions I tried should work, as long as the control knows which controls they are pointing to. When I figured it out, it felt like a dumb mistake but hope this can help someone(: 

Reply