Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 08:06 AM
want to get total number of days from today to date incident 'created'
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('sys_id', '4728cc7587f81110872b40cf8bbb3543');
incidentGR.query();
if (incidentGR.next()) {
var today = new GlideDate();
var endDate = incidentGR.sys_created_on.getDisplayValue().split(' ')[0];
var diff = GlideDate.subtract(today, endDate);
var days = diff.getRoundedDayPart();
gs.info(day);
}
ERROR im getting
Solved! Go to Solution.
Labels:
- Labels:
-
Scripting and Coding
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 09:17 AM
Hi,
update as this
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('sys_id', '4728cc7587f81110872b40cf8bbb3543');
incidentGR.query();
if (incidentGR.next()) {
var today = new GlideDateTime();
var endDate = new GlideDateTime(incidentGR.sys_created_on);
var diff = GlideDateTime.subtract(today, endDate);
var days = diff.getRoundedDayPart();
gs.info(day);
}
regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 10:02 AM
thnx Ankur it worked i thought glideDate() only will do the job but i've to learn about getRoundedDayPart()