number of week days

5 pts.
Tags:
Oracle development
How do i find out the number of weekdays in a date range in oracle.
ASKED: December 29, 2008  9:16 AM
UPDATED: January 16, 2009  2:31 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

I think you will need to create your own function to achieve that.

Something like this:

<pre>create or replace FUNCTION weekdays_between (p_date1 in date, p_date2 in date) RETURN number IS
l_weekdays number := 0;
l_current_date date := p_date1;
BEGIN
if p_date1 > p_date2 then
return 0;
end if;
while l_current_date <= p_date2 loop
if to_char(l_current_date,’d') not in (1,7) then
l_weekdays := l_weekdays + 1;
end if;
l_current_date := l_current_date + 1;
end loop;
return l_weekdays;
END;</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following