- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 10:54 AM
Hi All,
I have written a below scheduled script which is capturing days in three figure.
update_days();
function update_days() {
var gr = new GlideRecord("sc_req_item");
gr.addQuery('Active', true);
gr.query();
while (gr.next()) {
var datediff = gs.dateDiff(gs.nowDateTime(), gr.u_resolved.getDisplayValue(), false);
var days = datediff.split("");
//var days = datediff;
gr.u_duration = days[0] + days[1] + days[2];
gr.update();
}
}
But when I check the count of days remaining from Now to close date, it is showing it is fetching the time also..
according to <gr.u_duration = days[0] + days[1] + days[2];> I am getting this time value that is 2 after number of days. Is there any Possibility to remove the time from the above duration field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 12:16 PM
Replace var days = datediff.split(""); with var days = datediff.split(" "); , to split on the bases of space.
Then use gr.u_duration = days[0]; as it will contain actual number of days irrespective of number of figures.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 12:26 PM
Thanks Muhammad.