954,152 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Get all the months that have 31 days

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:

SELECT distinct TO_CHAR(dt,'MON') MONTH
FROM ( SELECT TRUNC(SYSDATE,'y')-1+ROWNUM dt
FROM all_objects
WHERE ROWNUM <= 366)
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.

tanta
Newbie Poster
1 post since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Hi,

you may try:

select * from yourtable where TO_CHAR(your_date, 'MM') in ('01', '03',... ,'12')


krs,
tesu

tesuji
Master Poster
721 posts since Apr 2008
Reputation Points: 158
Solved Threads: 98
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You