Connecting Tech Pros Worldwide Help | Site Map

display dates in a month

  #1  
Old May 14th, 2009, 08:38 AM
Newbie
 
Join Date: Nov 2008
Posts: 6
hi,
hope the query is simple, but i donno how to do.
i have some records in a table for the month may 2009 as
no date
---------------------------------------
1 02-may-09
4 10-may-09
13 12-may-09
20 24-may-09

only 4 days in may 09. but i want to display like
date no
-----------------------------------------
01-may-09 0
02-may-09 1
03-may-09 0
.
.
10-may-09 4
11-may-09 0
12-may-09 13
.
.
31-may-09 0

finally i need to display 31 days[all days ]in a month
how to do it in query. creating a view with this is needed for me.
pls help me..

thanks in advance..
muthu
  #2  
Old June 29th, 2009, 10:55 AM
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,188

re: display dates in a month


Try this:

Data in table1:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> SELECT * FROM table1;
  3.  
  4. 29-JUN-09    1
  5. 30-JUN-09    2
  6. 01-JUL-09    3
  7. 02-JUL-09    4
  8.  
  9. SQL> SELECT dt,no FROM
  10. (SELECT dt,NVL(rn,0) no FROM
  11. (select TRUNC(SYSDATE,'RRRR') + rn - 1 dt FROM
  12. (SELECT rownum rn from all_objects where rownum <= DECODE(MOD(TO_CHAR(SYSDATE,'RRRR'),4),0,366,365))) x,
  13. table1
  14. WHERE TO_CHAR(x.dt,'DD-MON-RRRR') = (TO_CHAR(y.dat(+),'DD-MON-RRRR'))
  15. AND TO_CHAR(dt,'MON-RRRR') IN (SELECT DISTINCT TO_CHAR(dat,'MON-RRRR') FROM table1))
  16. ORDER BY dt
  17.  
  18.  
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying dates in Datagrid. chethana answers 1 July 18th, 2007 02:51 PM
to display all the dates in a choosen month and year jai80 answers 1 April 2nd, 2007 09:48 AM
Grouping by Dates in a Report Miguelito Bain answers 3 November 12th, 2005 08:52 PM
Storing Dates in DB Angelos answers 8 July 17th, 2005 02:46 PM