Home » Developer & Programmer » Forms » Sundays with date (Oracle)
Sundays with date [message #611636] Sat, 05 April 2014 00:31 Go to next message
mehboob110233
Messages: 55
Registered: February 2014
Location: Pakistan
Member

Dear all,
I want a query that give me date and sunday from dual

like
day date
sunday 01-jan-2014
sunday 08-jan-2014
.
.
.
sunday 31-jan-2014




how i can do it
Re: Sundays with date [message #611639 is a reply to message #611636] Sat, 05 April 2014 03:00 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Sundays in 2014 (so far):
SQL> with dates as
  2    (select trunc(sysdate, 'yyyy') + level - 1 col
  3     from dual
  4     connect by level <= sysdate - trunc(sysdate, 'yyyy')
  5    )
  6  select col, to_char(col, 'day') day
  7  from dates
  8  where to_char(col, 'd') = 7;

COL        DAY
---------- ---------
05.01.2014 sunday
12.01.2014 sunday
19.01.2014 sunday
26.01.2014 sunday
02.02.2014 sunday
09.02.2014 sunday
16.02.2014 sunday
23.02.2014 sunday
02.03.2014 sunday
09.03.2014 sunday
16.03.2014 sunday
23.03.2014 sunday
30.03.2014 sunday

13 rows selected.

SQL>


Note that you might need to modify this line:
to_char(col, 'd') = 7;
if Sundays aren't day number 7 in your country.
Previous Topic: How to create formula column in sql statment
Next Topic: webutil_file_transfer.AS_to_Client always retrun false
Goto Forum:
  


Current Time: Fri Apr 26 23:07:38 CDT 2024