- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 06:49 AM
I am pulling in change records for the week using notification script... what i want to do is, compare the planned start date (just the date not time) to current date and highlight the cell... Issue i am running is that, planned start date field has both date and time but i want just the date to be compared.. Thanks, Malaya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2016 10:07 AM
Thank Jake..
Your piece of code helped me figure out the right piece so thank you for that...
This is what worked for me:
var gdt= new GlideDateTime(gr.getDisplayValue('start_date'));
var startDate = gdt.getLocalDate();
var gdt1= new GlideDateTime(gs.nowDateTime());
var compareDate = gdt1.getLocalDate();
if(compareDate.compareTo(startDate)==0){
template.print("<td bgcolor=#cde4f4>");
template.print(gr.getDisplayValue('start_date'));
}
else {
template.print("<td>");
template.print(gr.getDisplayValue('start_date'));
}
Thanks everyone for your inputs..
Thanks,
Malaya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2016 10:07 AM
Thank Jake..
Your piece of code helped me figure out the right piece so thank you for that...
This is what worked for me:
var gdt= new GlideDateTime(gr.getDisplayValue('start_date'));
var startDate = gdt.getLocalDate();
var gdt1= new GlideDateTime(gs.nowDateTime());
var compareDate = gdt1.getLocalDate();
if(compareDate.compareTo(startDate)==0){
template.print("<td bgcolor=#cde4f4>");
template.print(gr.getDisplayValue('start_date'));
}
else {
template.print("<td>");
template.print(gr.getDisplayValue('start_date'));
}
Thanks everyone for your inputs..
Thanks,
Malaya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 06:52 AM
You should check out the GlideDateTime - ServiceNow Wiki and look at functions such as getLocalDate(). That will output only the date and allow you to compare in some fashion. At that point i would maybe say take on the compareTo() also.