Pradyumna Das
Tera Expert
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 02-11-2022 07:25 AM
Run the below function in the background script to calculate total Working days using Schedule.
function getDiff(date1, date2) {
/*
@param1- Date value
@parm2- Date value
@return- woking days value in second
*/
var updatedDate = new GlideDateTime(date1); //old date
var currDate = new GlideDateTime(date2); //latest date
var schedID = 'Pass the sys_id'; //Parent sys_id of the schedule
var durationCalculator = new DurationCalculator();
durationCalculator.setSchedule(schedID);
var diff;
if (currDate > updatedDate) {
diff = durationCalculator.calcScheduleDuration(updatedDate, currDate);
} else {
diff = durationCalculator.calcScheduleDuration(currDate, updatedDate);
}
if (diff != '' || diff != 0 || diff != '0' || diff != undefined || diff != null)
return diff; //diff / 60 / 60 / 24 - To convert into days
return 0;
}
gs.info(getDiff('2022-02-11 15:23:25','2022-02-18 15:23:25'));
gs.info(getDiff('2022-02-11','2022-02-18'));
Please Mark it helpful if it helps you.
- 2,744 Views