Hello
I am trying to validate a Date|Time with the current Date|Time so that it does not allow the user to submit the request when the selected date & time is less than current date/time.
I have tried following rules:
FromDate<Current Date
This validation works only if the FromDate is less than CurrentDate but excludes the time.
The time needs to be also validated so that a booking cannot be submited when date and time are in the past!
formatDate(FromDate, 'dd/MM/yyyy HH:mm') < formatDate(Current Date, 'dd/MM/yyyy')+ formatDate(Current Time, ' HH:mm')
This validation does not allow even if you select date/time is well in the future.
I am confused
Solved! Go to Solution.
Yes, I did searched on here about a solution and I was not able to solve it ...
Indeed, also used the Form Variable to generate the CurrentDate/Time and use it to validate the FromDate but no luck.
The below solution seems to work for me.
Hi Eric
I guess you missed out that I require both: DATE and TIME.
Therefore, selecting "date only" makes the time selection disappear.
I already tried the LessThan function but again, it only validayes the date and ignores the time.
Ideally, I need a validation that checks if date is less then currentDate and if time is less than currentTime.
This validation works only if the FromDate is less than CurrentDate but excludes the time.
CurrentDate reference variable always evaluates to midnight.
formatDate(FromDate, 'dd/MM/yyyy HH:mm') < formatDate(Current Date, 'dd/MM/yyyy')+ formatDate(Current Time, ' HH:mm')
This validation does not allow even if you select date/time is well in the future.
formatDate evaluates to string so obviously it can not compare dates correctly. at least not with used date format.
as well "+" in this case just concatenates strings and not add up two dates
you have few options how to proceed, eg
- convert date and time to comparable string formats, eg. "yyyyMMddhhmi"
- add a date control on the form and set its default value to 'Today' and let it include time as well. reference value of this control in your calculations.
note the value gets evaluated at form load and doesn't recalculate during form session. plus (for unknown reasons) it always rounds up to next full hour.
- add form variable and set its formula to:
new Date ()
(note the space between "Date" and "()" )
(note2: this will not work on responsive forms and nintex mobile)
- code your own javascript validation (will not work on responsive forms and nintex mobile)
@emha wrote:This validation works only if the FromDate is less than CurrentDate but excludes the time.
CurrentDate reference variable always evaluates to midnight.
formatDate(FromDate, 'dd/MM/yyyy HH:mm') < formatDate(Current Date, 'dd/MM/yyyy')+ formatDate(Current Time, ' HH:mm')
This validation does not allow even if you select date/time is well in the future.
formatDate evaluates to string so obviously it can not compare dates correctly. at least not with used date format.
as well "+" in this case just concatenates strings and not add up two dates
you have few options how to proceed, eg
- convert date and time to comparable string formats, eg. "yyyyMMddhhmi"
- add a date control on the form and set its default value to 'Today' and let it include time as well. reference value of this control in your calculations.
note the value gets evaluated at form load and doesn't recalculate during form session. plus (for unknown reasons) it always rounds up to next full hour.
- add form variable and set its formula to:
new Date ()(note the space between "Date" and "()" )
(note2: this will not work on responsive forms and nintex mobile)
- code your own javascript validation (will not work on responsive forms and nintex mobile)
So what is your advice if you want to have something simple like this:
date & time input value must not be greater NOW.
I need this for a responsive form.
Cheers
mai-kel
So what is your advice if you want to have something simple like this:
kick the NINTEX so that they wake up and make date/time arithmetics usable in their products...
you see options I mentioned above, exclude those that are javascript based and doesn't work resp. aren't supported on responsive forms, forget about 'NOW' with precision better then midnight (resp. in specific circumstances at most next full hour) and you're left with no real possibilities how to achieve what you'd like...