Home » SQL & PL/SQL » SQL & PL/SQL » Any function to calculate weekends... (Oracle9i)
Any function to calculate weekends... [message #279346] Wed, 07 November 2007 19:57 Go to next message
dasgupta.amitava@gmail
Messages: 32
Registered: November 2007
Member
Hi,
Can anybody tell me about any function in Oracle9i, which can count the weekends(sat and sun) between two given dates.......

No sql or pl/sql logic pls....pure Oracle9i func.


Thanks in advance
Amitava..........
Re: Any function to calculate weekends... [message #279376 is a reply to message #279346] Thu, 08 November 2007 00:39 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'd also like to know if there's a built-in function which calculates number of holidays in Croatia between two dates. ./fa/1600/0/

Perhaps there is something like that; check the documentation and find the answer by yourself.
Re: Any function to calculate weekends... [message #279377 is a reply to message #279346] Thu, 08 November 2007 00:42 Go to previous messageGo to next message
Michel Cadot
Messages: 64130
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
-, /, * and trunc are the functions.

Regards
Michel
Re: Any function to calculate weekends... [message #279400 is a reply to message #279346] Thu, 08 November 2007 01:50 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I'm curious - in what way is SQL not Oracle 91 functionality?

If you want a builtin function that will return the number of weekend days between two dates, then I'm afraid you're out of luck.

Re: Any function to calculate weekends... [message #279570 is a reply to message #279346] Fri, 09 November 2007 01:29 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Amitava ,

Why do you want to use only built-in function not any SQL logic for for you purpose ? I think this is an interview question Very Happy


If every thing is provided by Oracle , where is the scope for Developer's Creativity ? Wink

Thumbs Up
Rajuvan
Re: Any function to calculate weekends... [message #279731 is a reply to message #279570] Fri, 09 November 2007 16:20 Go to previous messageGo to next message
dasgupta.amitava@gmail
Messages: 32
Registered: November 2007
Member
Dear Raj..
show ur Developer's Creativity and tell an effective logic for that....I am stuck up in such a position where Developer's Creativity died.
So, pls help me if you can....
Re: Any function to calculate weekends... [message #279766 is a reply to message #279731] Sat, 10 November 2007 03:37 Go to previous messageGo to next message
Michel Cadot
Messages: 64130
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You are stuck to what? Finding a built-in function that does not exist or writing a function that count the we?

Regards
Michel
Re: Any function to calculate weekends... [message #279927 is a reply to message #279346] Sun, 11 November 2007 23:01 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

I think , Amitava is on track ..

The following query may give you a strart you needed.

with fdate as(
select TO_DATE('01082007','DDMMYYYY') fromday  , TO_DATE ('01102007','DDMMYYYY') today ,
	    TO_DATE('01102007','DDMMYYYY')   - TO_DATE ('01082007','DDMMYYYY') diff from dual)
select   sum(DECODE(TO_CHAR(fromday + level-1,'DY'),'SAT',1,'SUN',1,0)) X    from fdate 
connect by level<= diff+1


Thumbs Up
Rajuvan
Re: Any function to calculate weekends... [message #280100 is a reply to message #279927] Mon, 12 November 2007 08:32 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
That's no good - the OP clearly specified no SQL
Re: Any function to calculate weekends... [message #280232 is a reply to message #279346] Mon, 12 November 2007 21:38 Go to previous message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member


I replied

Quote:

If every thing is provided by Oracle , where is the scope for Developer's Creativity ?


OP replied

Quote:

Dear Raj..
show ur Developer's Creativity and tell an effective logic for that


ie, OP was interested in *SQL Developer's creativity* Smile

Thumbs Up
Rajuvan
Previous Topic: Re:Triggers for Ms acess database
Next Topic: Query for Average , sum based on Type
Goto Forum:
  


Current Time: Wed Dec 07 10:21:45 CST 2016

Total time taken to generate the page: 0.13488 seconds