Calculating the number of working days between two given dates
Hi
I want to calculate dates difference between two randomly selected days (weekdays only).
Eg: Input – Leave Start Date and Leave end date
Output – Difference in week days (exclusive of weekend days)
Current script to calculate date difference in full:
getValue: function(attribute, workItem, configuration) {
var startDate = dojo.date.stamp.fromISOString(workItem.getValue("leaveStartDate"));
var endDate = dojo.date.stamp.fromISOString(workItem.getValue("leaveEndDate"));
var daysDifference = dojo.date.difference(startDate,endDate, "day");
return daysDifference;
}
Appreciate your help.
DK
Comments
Donald Nong
Dec 21 '17, 8:01 p.m.I believe you need a localized calendar for this function, which to my knowledge does not exist. For example, Christmas day is a non-working day in most Western countries, but remains a working day in most Asian countries.
1 vote
Dulsanka Kulasinghe
Dec 28 '17, 6:27 a.m.Thanks for the comment Donald and indeed it’s a valid point. Leaving the calendar function for further developments, do you have any idea how can we at least ignore the weekend from a day count.
Thanks - DK