Validating a selected Date

  • 25 October 2018
  • 1 reply
  • 4 views

Badge +11

Hi,

I am trying to validate the date in a form via the rules and there are two fields: StartDate and EndDate.
The purpose is to validate the date and time when:

  • StartDate (including time) is equal to or greater than the EndDate (including time)

For example the below entry throws the error because it sees that 00:00 is lass then 08:00
which in fact are 8 hours from 00:00 midnight until 8:00am

StartDate:    25/10/2018 00:00
EndDate:     25/10/2018 08:00

The new formula should validate when dates are equal and the Time in EndDate is less than in StartDate otherwise let it go through any time when endDate is more than startDate. In simple term, dis-allow date/time in the past!

Validation formula used:

formatDate(FromDate, "dd/MM/yyyy hh:mm") > formatDate(UntilDate, "dd/MM/yyyy hh:mm")


1 reply

Badge +11

Ahhh silly me!
I was using the wrong date formatting hh:mm and it should be HH:mm

hh:mm > uses the 12 hr format
HH:mm > uses the 24 hr format

Hence why my validation did not work happy.png of course.

formatDate(FromDate, "dd/MM/yyyy HH:mm") > formatDate(UntilDate, "dd/MM/yyyy HH:mm")

Reply