RE: Vs: Function to calculate weekdays left in a month
- From: "Bobak, Mark" <Mark.Bobak@xxxxxxxxxxxx>
- To: "jack@xxxxxxxxxxxx" <jack@xxxxxxxxxxxx>, Teijo Lallukka <teijo.lallukka@xxxxxxxx>
- Date: Mon, 4 Aug 2008 04:07:26 -0400
Try this:
select sum((case trim(to_char(sysdate+level-1,'Day'))
when 'Saturday'
then 0
when 'Sunday'
then 0
else 1 end)) weekdays_left_this_month
from dual
connect by level <= trunc(last_day(sysdate))-trunc(sysdate)+1
As written, it includes the current day in the count.
Hope that helps,
-Mark
________________________________________
From: oracle-l-bounce@xxxxxxxxxxxxx [oracle-l-bounce@xxxxxxxxxxxxx] On Behalf
Of Jack van Zanen [jack@xxxxxxxxxxxx]
Sent: Monday, August 04, 2008 1:54 AM
To: Teijo Lallukka
Cc: oracle-l@xxxxxxxxxxxxx
Subject: Re: Vs: Function to calculate weekdays left in a month
If only it were that simple.
That gets me all the days and I am interested in the weekdays only.
Brgds
Jack
On 04/08/2008, Teijo Lallukka
<teijo.lallukka@xxxxxxxx<mailto:teijo.lallukka@xxxxxxxx>> wrote:
Hi!
try this, this can help you.
SQL> SELECT SYSDATE,
LAST_DAY(SYSDATE) "Last",
LAST_DAY(SYSDATE) - SYSDATE "Days Left"
FROM DUAL;
SYSDATE Last Days Left
1 4.8.2008 8:48:16 31.8.2008 8:48:16 27
-TL
-----------------------------------------------------------------------------
Teijo Lallukka, Oracle DBA
teijo.lallukka@xxxxxxxx<mailto:teijo.lallukka@xxxxxxxx> http://www.edita.fi
-----------------------------------------------------------------------------
www.edilex.fi<http://www.edilex.fi> | www.finlex.fi<http://www.finlex.fi> |
www.credita.fi<http://www.credita.fi>
-----------------------------------------------------------------------------
>>> "Jack van Zanen" <jack@xxxxxxxxxxxx<mailto:jack@xxxxxxxxxxxx>> 4.8.2008
>>> 8:45:39 >>>
Hi All,
I am not a programmer and before I spend a lot of time on some PL/SQL to do
this I would just like to double check if anybody on this list has created
such a function/proc already.
Brgds
--
J.A. van Zanen
--
J.A. van Zanen
--
http://www.freelists.org/webpage/oracle-l
- Follow-Ups:
- RE: Vs: Function to calculate weekdays left in a month
- From: Mark W. Farnham
- References:
- Re: Vs: Function to calculate weekdays left in a month
- From: Jack van Zanen
Other related posts:
- » Re: Vs: Function to calculate weekdays left in a month
- » RE: Vs: Function to calculate weekdays left in a month
- » RE: Vs: Function to calculate weekdays left in a month
- » Re: Vs: Function to calculate weekdays left in a month
- » RE: Vs: Function to calculate weekdays left in a month
- » Re: Vs: Function to calculate weekdays left in a month
- » RE: Vs: Function to calculate weekdays left in a month
- » Re: Vs: Function to calculate weekdays left in a month
- » Re: Vs: Function to calculate weekdays left in a month
- RE: Vs: Function to calculate weekdays left in a month
- From: Mark W. Farnham
- Re: Vs: Function to calculate weekdays left in a month
- From: Jack van Zanen