Compare two date fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2017 07:02 AM
Hi All,
I have a requirement that have to compare start date and end date, if start date is greater than the end date need to show alert using on change client script.
i tried with below code but not working. any one guide me on this.
var st = g_form.getValue('u_start_time');
var et = g_form.getValue('u_end_time');
if(st > et)
{
alert("Start time should be less than the end time");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2017 07:06 AM
Hi Anil,
If they are only of type date then following link should be helpful:
In Client Script, how can I compare 2 dates(with time) that are in different format.
Client script to validate start/end date fields
Compare 2 Dates in On Load Client script.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 09:31 AM
Please help me
https://community.servicenow.com/community?id=community_question&sys_id=aa6f9ebb1b23d810d2ccea89bd4bcbef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2017 07:27 AM
Hello Anil
This thread will help you
How do I ensure one date field does not start before another date field?
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 04:59 AM
Hi Anil,
Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader