Home » SQL & PL/SQL » SQL & PL/SQL » Days in between Two Dates
Days in between Two Dates [message #7794] Wed, 09 July 2003 09:24 Go to next message
Thivya
Messages: 1
Registered: July 2003
Junior Member
Hi
How to find the N.of Mondays in between two dates using a simple query.
Re: Days in between Two Dates [message #7798 is a reply to message #7794] Wed, 09 July 2003 12:37 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select count(*)
  from (select :dfrom + rownum - 1 dt
          from all_objects
         where rownum <= (:dto - :dfrom))
 where to_char(dt, 'd') = 2;
Re: Days in between Two Dates [message #7819 is a reply to message #7798] Thu, 10 July 2003 09:48 Go to previous messageGo to next message
inna
Messages: 6
Registered: July 2002
Junior Member
Todd, I think you will get more accurate result with
this query (try to choose some Mondays for both dfrom and dto)

select count(*)
from (select :dfrom + rownum - 1 dt
from all_objects
where rownum <= (:dto - :dfrom+1))
where to_char(dt, 'd') = 2;
Re: Days in between Two Dates [message #7821 is a reply to message #7819] Thu, 10 July 2003 11:29 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Agreed - thanks for catching that...
Previous Topic: table level triggers
Next Topic: help required with date format in select statement
Goto Forum:
  


Current Time: Wed Apr 24 10:25:58 CDT 2024