Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Adviise please
maruf.zubaer_at_citigroup.com wrote:
: I need assistance in creating an oracle function which will calculate
: DateTimeDiff in hours excluding weekends and holidays
: So if Statdate is 10/10/05 08:15:00 and EndDate 10/10/05 13:15:00 the
: result we get is 5.00 hrs
One straight forward approach
find the hours left in the first day
if the first day is not a holiday or a weekend then add them
now loop through each day until the penultimate
if each day is not a holiday or a weekend then add 24 hrs
find the hours taken up in the last day
if the day is not a holiday or a weekend then add those hrs also
How you decide a day is a weekend is to use one of the date functions that tells you which day it is (mon, tue, etc).
How you decide a day is a holiday is your problem.
Mr. Morgan showed a few sample date calculations to get you started on the syntax and a few basic ideas that are involved in oracle date calculations.
-- This programmer available for rent.Received on Fri Oct 21 2005 - 12:03:05 CDT
![]() |
![]() |