Home > Ask the Oracle Database / Applications Experts > Questions & Answers > Difference between two dates using office hours
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Difference between two dates using office hours

Rudy Limeback EXPERT RESPONSE FROM: Rudy Limeback

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 22 May 2001

I need to calculate the difference between two dates and display the result as the number of weeks, days, hours and minutes. This in itself is not a problem, but I want to use only office hours in the query, i.e., ignore weekends and do not calculate hours after 18:30 and before 08:00, public holidays excluded etc.


>

The best way to approach this problem is with the use of a Calendar table. Office hours are from 08:00 to 18:30? Okay, that's 10.5 hours.

Caldate     DayOfWeek  OfficeHours  Holiday
2001-05-24   Thu        10.5
2001-05-25   Fri        10.5
2001-05-26   Sat        0
2001-05-27   Sun        0
2001-05-28   Mon        0           Memorial Day
2001-05-29   Tue        10.5

To find the office hours between two dates, you use a query like this --

select sum(OfficeHours)
  from Calendar
 where Caldate >= #startdate#
   and Caldate <  #enddate#

where #startdate# and #enddate# are your variables.

The main task then will be updating the Calendar table annually -- probably by hand, i.e. by preparing the data in, say, Excel, and then loading it into the table with a database utility.

For More Information


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts