RE: Vs: Function to calculate weekdays left in a month

From: Bobak, Mark <Mark.Bobak_at_proquest.com>
Date: Mon, 4 Aug 2008 04:07:26 -0400
Message-ID: <667C10D184B2674A82068E06A78382B523C8F2B4@AAPQMAILBX01V.proque.st>


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_at_freelists.org [oracle-l-bounce_at_freelists.org] On Behalf Of Jack van Zanen [jack_at_vanzanen.com] Sent: Monday, August 04, 2008 1:54 AM
To: Teijo Lallukka
Cc: oracle-l_at_freelists.org
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_at_edita.fi<mailto:teijo.lallukka_at_edita.fi>> 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@edita.fi<mailto:teijo.lallukka@edita.fi> 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_at_vanzanen.com<mailto:jack_at_vanzanen.com>> 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
Received on Mon Aug 04 2008 - 03:07:26 CDT

Original text of this message