943,579 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 3037
  • Oracle RSS
Jul 23rd, 2008
0

Get all the months that have 31 days

Expand Post »
Hi,
I am a junior dev. and I need help on some select statements on a Oracle db.
First I needed to get all the months of the year in 'MON' format and I did it like this:

sql Syntax (Toggle Plain Text)
  1. SELECT DISTINCT TO_CHAR(dt,'MON') MONTH
  2. FROM ( SELECT TRUNC(SYSDATE,'y')-1+ROWNUM dt
  3. FROM all_objects
  4. WHERE ROWNUM <= 366)
  5. ORDER BY TO_DATE( MONTH, 'MON' )

Now, I need another statements to get only the month that have 31 days, then 30 days the leap year.

I cannot create strings that have the names like JANFEBMAR.. and then compare because we use this in a multilingual environment.

Any help would be appreciate it.
Last edited by peter_budo; Jul 23rd, 2008 at 8:11 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tanta is offline Offline
1 posts
since Jul 2008
Jul 25th, 2008
0

Re: Get all the months that have 31 days

Hi,

you may try:

sql Syntax (Toggle Plain Text)
  1. SELECT * FROM yourtable WHERE TO_CHAR(your_date, 'MM') IN ('01', '03',... ,'12')

krs,
tesu
Last edited by peter_budo; Jul 26th, 2008 at 5:11 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 158
Solved Threads: 98
Master Poster
tesuji is offline Offline
720 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: Oracle Server Version
Next Thread in Oracle Forum Timeline: Database driver and provider





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC