Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: removing weekends?
John Hoskins wrote:
>
> Hi,
> I want to subtract two dates, and get the number of 'working' days, in
> other words not count the weekend days. Is their a way to do this in the
> select clause? Or will I need to do it in more than one step.
> Any help would be appreciated,
> John Hoskins
> john.hoskins_at_teldta.com
You could do it in a the select clause but it would be rather hairy. I would suggest writing stored function to do it in PL/SQL, then use the function in your SQL statement. For example:
CREATE OR REPLACE FUNCTION working_days_between
(date1 in DATE, date2 IN DATE)
RETURN NUMBER IS
SELECT order_id, order_desc
FROM orders
WHERE working_days_between(order_date, ship_date) > 5;
Chris Halioris
Tactics, Inc.
hali_at_tacticsus.com
Received on Thu Mar 06 1997 - 00:00:00 CST