Highlighted
Micro Focus Expert
Micro Focus Expert
63 views

Validating a date field to be in the future or today

Jump to solution

I have a date field (not a date_time field). I setup an After Change rule to validate the field and give a "date must be in the future" message as needed. Originally, my rule was:

${entity.CENextStepsDate_c >= now()}

This works fine to verify that the date is in the future. But, now the users also want to be able to enter today's date. I thought the "greater than or equal" would have worked, but it does not. With the rule above, if they enter today's date, they still get the "date must be in the future" message. 

I tried changing the rule to be:

${entity.CENextStepsDate_c >= (now()-86400000)}

But, this gives an error "Expression entity.CENextStepsDate_c >= (now()-86400000) includes invalid characters." I tried without the parens and got the same message.

Any advice? 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Please try adding some spaces:

now() - 86400000

 

As for the comment about using today's date, if the field is a date field, the date entered will be converted into epoch time midnight, that's why you have to add the "buffer".

Best regards,

Brindusa

 

View solution in original post

2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Please try adding some spaces:

now() - 86400000

 

As for the comment about using today's date, if the field is a date field, the date entered will be converted into epoch time midnight, that's why you have to add the "buffer".

Best regards,

Brindusa

 

View solution in original post

Highlighted
Micro Focus Expert
Micro Focus Expert

It worked! Thank you 😊

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.