- 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 11:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 11:36 AM
Hi Chirag,
Replace gr.u_duration = days[0] + days[1] + days[2]; with gr.u_duration = days[0];
Hopefully this will resolve your problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 11:50 AM
Hi ,
It will not resolve my problem as days[0] only return the first figure of the number.
Like for example, no. of days is 18, then days[0] will return 1. If it take days[0] + days[1], it will return 18. May be in future, requirement will be in three figures so i have taken days[0]+days[1]+days[2].
- 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.