Creating a Calendar (merged 3 topics) [message #259798] |
Thu, 16 August 2007 09:26  |
vikky538
Messages: 2 Registered: August 2007
|
Junior Member |
|
|
hi friends am new to this forum am unable to find .the code for calender especially in SQL(only in SQL ) so plz if any body helps thats a gr8 thing for me..plz post u r replies...with the relevent results...thnk u very much....if u wanna mail me u can mail me to mail id........
|
|
|
Re: SQL code for calender [message #259800 is a reply to message #259798] |
Thu, 16 August 2007 09:32   |
Cthulhu
Messages: 381 Registered: September 2006 Location: UK
|
Senior Member |
|
|
I have no idea whatsoever what you mean by "calendar". Will this do ?
select to_date('01-jan-2007', 'DD-MON-YYYY')+level-1 as thedate
from dual
connect by level <= 365
|
|
|
|
|
|
Re: Generate Sequence number using SQL query in Oracle 9i [message #259952 is a reply to message #259948] |
Thu, 16 August 2007 23:27   |
samyugtha
Messages: 14 Registered: November 2005
|
Junior Member |
|
|
Thanks for the reply,
But its not a home work assignment. I have to generate month list from Jan - Dec using SQL query in my report. So if I get a logic of generation of sequence number, I can generate the list of months.
Help me if you know the answer otherwise dont criticize.
Thanks.
|
|
|
|
|
|
|
|
Re: Generate Sequence number using SQL query in Oracle 9i [message #260116 is a reply to message #260096] |
Fri, 17 August 2007 08:57   |
 |
Michel Cadot
Messages: 68737 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Samyugtha, Sanka,
Any of your quries works in 9i.
SQL> select TO_CHAR(TO_DATE(rownum,'MM'),'Mon') Month_Val from dual connect by rownum <= 12;
MON
---
Jan
1 row selected.
SQL> select TO_CHAR(TO_DATE(level,'MM'),'Mon') Month_Val from dual connect by level <= 12;
MON
---
Jan
1 row selected.
You have to use:
SQL> select TO_CHAR(TO_DATE(rownum,'MM'),'Mon') Month_Val
2 from (select 1 from dual connect by rownum <= 12)
3 /
MON
---
Jan
Fev
Mar
Avr
Mai
Jun
Jul
Aou
Sep
Oct
Nov
Dec
12 rows selected.
SQL> select TO_CHAR(TO_DATE(rownum,'MM'),'Mon') Month_Val
2 from (select 1 from dual connect by level <= 12)
3 /
MON
---
Jan
Fev
Mar
Avr
Mai
Jun
Jul
Aou
Sep
Oct
Nov
Dec
12 rows selected.
Regards
Michel
|
|
|
|
|
creating a calendar [message #260154 is a reply to message #259798] |
Fri, 17 August 2007 10:59   |
vasudhak
Messages: 1 Registered: August 2007
|
Junior Member |
|
|
Hi,
I have been given a SQL query which should generate a calendar i.e. from today's date(sysdate) till the same date of next year.
Can anyone give me an idea as to how I write it ?
I have seen a query which used a view - all_objects.
Can we write it using dual ? When I wrote a query using dual, it isn't working.
Can anyone help me out ?
I don't think we have any inbuilt function to create a calendar.......
[Updated on: Fri, 17 August 2007 11:09] Report message to a moderator
|
|
|
|
Re: creating a calendar [message #260634 is a reply to message #260154] |
Mon, 20 August 2007 09:31   |
vikky538
Messages: 2 Registered: August 2007
|
Junior Member |
|
|
ya buddy we hav to use rownum and we can make the code for the calender..but we need t use the basic query statements...dats the thing..
neway..thanks for u r participation....nice idea u got....keep it up....byeee
|
|
|
|