http://www.perlmonks.org?node_id=554942


in reply to determining work hours between 2 dates

The way we count workdays between 2 dates in data warehousing is to use a dimension table.

The Date Dimension will contain a row for every day in the calendar for a period of years; as far into the past as you are likely to care about, and at least 2 years into the future.
Each day is keyed with the date in date format (or you could use epochal date). There will be a column with a flag for Holiday, a flag for Weekday, and a flag for Workday.

We also have an aggregated column of Week_work_days_to_date, Month_work_days_to_date, Quarter..., Year..., Fiscal_year...; mainly because those are the most requested time spans.
If the time span you are interested in is not one of the standards, then you merely sum the the Workday flag for every day between your start and end dates.
  • Comment on Re: determining work hours between 2 dates