- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 01:43 PM
Hi,
I have created a string field on incident and trying to get total days of incident opened based on created date and todays date. Its showing time as well, how can I remove time and show only days.
var gr = new GlideRecord('incident');
gr.query();
while (gr.next()) {
var dat = new GlideDateTime();
var datedif = gs.dateDiff(gr.sys_created_on, dat);
gr.u_total_days = datedif;
gr.update();
}
Thanks,
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 04:21 PM
Hi reddy,
Try this please
var gr = new GlideRecord('incident');
gr.query();
while (gr.next()) {
var dat = new GlideDateTime();
var datedif = gs.dateDiff(gr.sys_created_on, dat);
gr.u_total_days = datedif.split(' ')[0];
gr.update();
}
Mark Correct and Helpful if it helps.
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 04:21 PM
Hi reddy,
Try this please
var gr = new GlideRecord('incident');
gr.query();
while (gr.next()) {
var dat = new GlideDateTime();
var datedif = gs.dateDiff(gr.sys_created_on, dat);
gr.u_total_days = datedif.split(' ')[0];
gr.update();
}
Mark Correct and Helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:05 AM
Hi,
I tried this, its not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:15 AM
Did you copy/pasted the code I shared above you probably missed the space in split(' '). otherwise it should work was working on my PDI
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:18 AM - edited 10-31-2022 08:19 AM
***Mark Correct or Helpful if it helps.***