compare two date fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 04:06 AM
i have two date fields
1)start date
2)end date
if start date is greater than end date,abort the form from submission
please help me with the businees rule script..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 04:14 AM
Hi Prashanth,
Use a client script with below code:
var start_d = getDateFromFormat(g_form.getValue('start_date'), g_user_date_time_format);
var end_d = getDateFromFormat(g_form.getValue('end_date'), g_user_date_time_format);
if (start_d > end_d) {
alert("End Date must not be before Start Date");
g_form.setValue('u_proposed_end_date', '');
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 09:29 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-12-2016 04:16 AM
GlideDateTime and the compareTo() function is probably what you are looking for.
Please refer to this wiki article where you can also find some example code to use in your Business Rule script.
Note, being usable in a Business Rule, that code will be working on the server side and you won't be able to use the same code in client side, e.g. in Client Scripts.
I hope it helps.
Regards,
Loris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 04:19 AM
I also found another wiki article which seems to do what you are looking for, including the aborting action (all done from a Business Rule).
Please see Comparing Two Date fields.
Regards,
Loris D'Avanzo