It's all about the answers!

Ask a question

Calculating the number of working days between two given dates


Dulsanka Kulasinghe (3811) | asked Dec 21 '17, 9:19 a.m.

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
1
Donald Nong commented 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.


Dulsanka Kulasinghe commented 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

Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.