Compare start date and end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:22 AM
I'm having problems when comparing two data/time fields in a service catalog. I have a start date that cannot be earlier than the current day/time and I have an end date field where this cannot be chosen with a date/time less than the start date or earlier.
I've tried both via scrip and via policy, but I'm stuck in this situation. Could you give me this support.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:35 AM
Hey,
You follow below links to attain this.
One way is to use onChange client script to compare the two dates:
Client Side Dates in ServiceNow
Another is using onChange script client script and GlideAjax GlideAjax, to compare the fields at server side:
Client Script Date Compare
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:43 AM
Hi there,
Have you considered using a (Catalog) UI Policy to achieve date validations? There's almost no-code needed to achieve date validations this way. Have a look at an article I wrote on this:
No Code date validations thru (Catalog) UI Policies
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 01:07 PM
Thank you very much for the support, but I ended up using the two merged forms, I did the validation of the start date via UI policies and the validation of the end date comparing with the start date if it will be before the date/time . This way I managed to solve my problem and the tests were carried out successfully. Thank you all for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 11:48 AM
To compare two dates from the Catalog Client side, you might need to call GlideAjax and use a script include to do the comparison.