cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
mjmarz
Nintex Newbie

How do I create a validation to make sure that one date field is within a given range of another date field?

Jump to solution

I am creating a form with two date fields, Start Date and Expiration Date.  I need to make sure that the Expiration Date is within 365 days of the Effective Date.  IE Start Date 1/1/2019 Expiration Date 12/31/2019 is VALID, but Start Date 1/1/2019 Expiration Date 2/28/2020 is invalid. I tried creating a validation range where minimum value was set to Effective Date, then tried using the following formula for Maximum Value:

    =fn-LessThanOrEqual(fn-DateDiffDays(Start Date, Expiration Date), 365) 

Unfortunately, this always came back as false, no matter what date was entered.

I also tried creating a validation rule using this formula:

lessThanOrEqual(dateDiffDays(Start Date,Expiration Date),365)

This also seems to always fail, regardless of the Expiration Date entered.

I'm not sure how to proceed from here.  I'm new to formulas and functions in Nintex and could use some guidance.  Also, if anyone has a link to a good basic tutorial on creating this formulas, it would be helpful.  Thank you!

0 Kudos
Reply
4 Replies
Nintex Employee
Nintex Employee

Re: How do I create a validation to make sure that one date field is within a given range of another date field?

Jump to solution

You're formula is correctly setup, but you should just have to wrap the 365 in quotes so it will look like the below:

Using this formula in a calculated value to show whether it evaluates correctly:

Thanks,

Dan

0 Kudos
Reply
mjmarz
Nintex Newbie

Re: How do I create a validation to make sure that one date field is within a given range of another date field?

Jump to solution

This is correct, I did need to add quotations around the 365 as shown above.  However, when making a validation rule in my version of Nintex forms, I also had to change from lessThanOrEqual to greaterThan.  The condition states that the control is INVALID if...  I was writing my control backwards, so after adding quotations, it would only validate if the expiration date was greater than one year from the start date.  Full correct formula in the validation rule control box:

Reply
mjmarz
Nintex Newbie

Re: How do I create a validation to make sure that one date field is within a given range of another date field?

Jump to solution

Also, make ABSOLUTELY SURE that you use "Named Controls" and not "Item Properties" when you are constructing this formula, or it will not work.  Not only will it not work, it will do all kinds of weird shit.  Wasted hours on that on another form today.  

0 Kudos
Reply
Nintex Employee
Nintex Employee

Re: How do I create a validation to make sure that one date field is within a given range of another date field?

Jump to solution

Hi Michael,


Good call out on that one.  Item properties will be referencing the list item properties, which if the form has not been saved, will not be populated.  If you're using Item properties, you'll only want to use them on the 'Edit Form' options where the form has already been submitted.  The 'Named Controls' will be pulling what's in the form rather than the data stored to the list.

Thanks,

Dan

Reply