want only the working hours(9am-5pm) between two dates, weekends should
be omitted..
i did this code..
but i need the total hours between 9am-5pm, between the given dates..
can any one plz help??
There's 8 hours between 9am-5pm, so 8 hour/working day.
There's 5 working day/week.
So if you can compute the number of weeks between the Monday following
the first date, and the Monday preceding the last date, you can easily
compute the number of working hours.
if week-of(start) = week-of(end) then
working-hours = working-hours/working-day * working-days(from start to end)
else
working-hours = working-hours/working-day * ( working-days(from start to end-of-week-after(start))
+ working-days(from beginning-of-week-before(end) to end)
+ working-days/working-weeks * working-weeks(from end-of-week-after(start)
to beginning-of-week-before(end)))
end
all i need is working hours between these dates...
first day & last days time makes complications here.
If you have partial days, apply the same principle than in my previous
answer, trim off the partial days, compute the trimmed off hours, and
multiply the days by the working-hours-per-day.
if day(start)=day(end) then
min(5pm,hour(end)) - max(9am,hour(start))
else
(min(5pm,hour(end)) - 9am)
+ (5pm - max(9am,hour(start)))
+ previous algo with (start + 1day) and (end - 1 day)
end