Compare two dates in Nintex Forms

  • 14 June 2017
  • 6 replies
  • 103 views

Userlevel 4
Badge +12

Hi everyone,

a customer is using a Nintex Forms 2016 list form to get some data from users. They use two text fields to catch two date values. They don't use calendar controls because the expected dates are long in the past and thus entering the dates with the date picker control is not very comfortable. Instead they use input masks to help the user.

After both dates are entered they want to compare both dates where Date A must not be after Date B. However as they are both text fields the comparison is not done numerical but by string comparison.

I tried to use runtime functions formatDate and convertToDate to try parsing both text values as date and compare them afterwards but with no success.

204187_pastedImage_1.png

Anyone has any ideas what other things I could try? Converting it in a workflow and getting back to the user is not really an option as the form is relatively complex which is why we'd like to do the validation directly in the form.

Thanks for any help.

Enrico


6 replies

Badge +9

Hi Enrico

no 2016 here but in 2013 following validation rule is working:

greaterThan(convertToDate(fdatum_von) , convertToDate(fdatum_bis) )

Kind regards

Manfred

Userlevel 4
Badge +12

Hi Manfred,

thanks for the quick relby. I tried that before but the convertToDate() function always puts out #Value!, thus the rule validates #Value! > #Value! instead of converted dates. It doesn't get that 01.06.2017 is a date :/

Userlevel 4
Badge +11

Hi Enrico,

I've done some test and here is what I've found:

using convertToDate(), the argument should be in a valid format based on the Regional Settings of the site (if you have the american format for the date, it should be Month/Day/Year, european format asks for day/month/year)

plus, I've test with regional settings English (United Kingdom), part of the date should be separated with a slash and not with a dot..if it's possible to change how users write the dates (30/05/2017 instead of 30.05.2017), then the function should work..

Giacomo

Badge +9

Hi Enrico Knapp‌,

You have to enter the dates as below to work with the 'convertToDate' function.

204247_pastedImage_2.png

204254_pastedImage_3.png

Other wise it will be difficult to convert the user format for date comparison.

Thanks,

Userlevel 4
Badge +12

Ugh... seems to be a problem with the German date format.

If I just use a formula to write down the date entered above it writes the date but except the dots. It just treats my date as a number, removes leading zeros and the dots.

The conversion of this value fails as described.

If I manually break up the value and readd the dots the conversion works...

Manfred Lauer‌, I wonder why this is happening to me. It seems to work in your environment with German format too.

Is there any way to force Nintex to just treat my string as a string?

Meh...

Userlevel 4
Badge +12

Finally ended up with reformatting all my "number" date and added dots manually to make conversion action work with German date format.

It works now but it's a lot of effort but at least it's working now.

Thanks for all suggestions though.

Enrico

Reply