- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 12:38 AM
I wanna compare a variable to a system field:
system field - closed (closed_at) type is date/time
variable - Requested end date (requested_end_date) type is date
want the sys_id's of only those tasks(sc_task) where closed date is greater than requested end date (closed > req_end_date)
i am using following code:
var ids = [];
var gr = new GlideRecord('sc_task');
gr.query();
while(gr.next())
{
var gdt1 = new GlideDateTime(gr.closed_at.getDisplayValue());
var requested_end_date = new GlideDateTime(gr.variables.requested_end_date);
//var result = gs.dateDiff(requested_end_date , gdt1,true);
if((requested_end_date != '' || requested_end_date != null ) && requested_end_date < gdt1){
ids.push(gr.sys_id.toString());
}
}
THE ABOVE CODE GIVES ME SYS_IDS EVEN IF CLOSED DATE IS LESS THAN REQ END DATE, WHEREAS IT SHOULD RETURN ONLY THE GREATER ONES.
Any help on this pls
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 12:57 AM
hi here you can compare both by considering only the date and not time
you just have to slice the time part and take the date part and pass it to datediff method using ajaxcall... this should work..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 12:50 AM
One way is that you may convert the date time to a string, and then re convert it to the date. Now you can compare the date fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 01:00 AM
Hi, thank you for your reply, i used .getDate() and then compared only the dates, it works now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 12:57 AM
hi here you can compare both by considering only the date and not time
you just have to slice the time part and take the date part and pass it to datediff method using ajaxcall... this should work..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2017 01:00 AM
Hi, thank you for your reply, i did the same, i used .getDate() and then compared only the dates, it works now.