Skip to content
Advertisement

Extract month from number of days in a year

I am trying to extract month from number of day in year in Oracle SQL, for instance day 32 is february.

I do not have permission to use procedure, so I have to do it just using select.

Any help?

Advertisement

Answer

You get to the solution as follows. First convert the day X into a date and extract the month from it again. Replace the value 150 with the day of the year you are looking for.

For Month as Number:

Works also with the year. Format of the to-date must be simply changed to match.

For Month as Month Name:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement