- 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-12-2016 06:51 AM
Here you go.
var gdt= new GlideDateTime();
gdt.setDisplayValue(current.<date time field name>);
gdt.getDate(); //this will give you the date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 02:29 PM
This gives me just the current system date.. Let me elaborate my case.. I am pulling a change report which has one of the columns as "Planned start date".. the value that it holds is date and time (2016-08-12 20:00:00).. what i want to do is just get the date from it and compare it against the system date and if the date matches then highlight the cell. so something like this: var gr = new GlideRecord("change_request"); if (gr.getDisplayValue('start_date') == gs.now()) { template.print(""); template.print(gr.start_date); } else { template.print(gr.start_date); }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 02:54 PM
Use this
var gdt= new GlideDateTime();
gdt.setDisplayValue(current.<field name of Planned Start Date>);
gdt.getLocalDate();
var gdt1= new GlideDateTime();
gdt1.setDisplayValue(gdt.getLocalDate());
var gdt2= new GlideDateTime();
gdt2.setDisplayValue(gs.now());
if(gdt1.compareTo(gdt2)==0){
template.print("");
template.print(gr.start_date);
}
else {
template.print(gr.start_date);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2016 07:16 AM
Doesn't work either... Also i didn't understand.. the first part.. var gdt= new GlideDateTime(); gdt.setDisplayValue(current.); gdt.getLocalDate(); why are we doing this? Thanks, Malaya