Get month name from date in Oracle

SqlOracleDate

Sql Problem Overview


How to fetch month name from a given date in Oracle?

If the given date is '15-11-2010' then I want November from this date.

Sql Solutions


Solution 1 - Sql

select to_char(sysdate, 'Month') from dual

in your example will be:

select to_char(to_date('15-11-2010', 'DD-MM-YYYY'), 'Month') from dual

Solution 2 - Sql

Try this,

select to_char(sysdate,'dd') from dual; -> 08 (date)
select to_char(sysdate,'mm') from dual; -> 02 (month in number)
select to_char(sysdate,'yyyy') from dual; -> 2013 (Full year)

Solution 3 - Sql

to_char(mydate, 'MONTH') will do the job.

Solution 4 - Sql

In Oracle (atleast 11g) database :

If you hit

select to_char(SYSDATE,'Month') from dual;

It gives unformatted month name, with spaces, for e.g. May would be given as 'May '. The string May will have spaces.

In order to format month name, i.e to trim spaces, you need

select to_char(SYSDATE,'fmMonth') from dual;

This would return 'May'.

Solution 5 - Sql

If you are trying to pull the value from a field, you could use:

select extract(month from [field_name])
from [table_name]

You can also insert day or year for the "month" extraction value above.

Solution 6 - Sql

Try this

select to_char(SYSDATE,'Month') from dual;

for full name and try this

select to_char(SYSDATE,'Mon') from dual;

for abbreviation

you can find more option here:

https://www.techonthenet.com/oracle/functions/to_char.php

Solution 7 - Sql

if you are taking system date:

--Full month name :
select to_char(trunc(sysdate,'MONTH'),'MONTH') as month from dual; --MARCH    
--Short month name:
select to_char(trunc(sysdate,'MON'),'MON') as month from dual; --MAR
--Month number:
select to_char(trunc(sysdate,'MM'),'MM') as month from dual;  --03

if you are taking a specific date:

--Full month's name:
select to_char(trunc(to_date('11-03-2021','DD-MM-YYYY'),'MONTH'),'MONTH') as month from dual; --MARCH
--Short month's name:
select to_char(trunc(to_date('11-03-2021','DD-MM-YYYY'),'MON'),'MON') as month from dual; --MAR
--Month's number:
select to_char(trunc(to_date('11-03-2021','DD-MM-YYYY'),'MM'),'MM') as month from dual;  --03

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNiraj ChoubeyView Question on Stackoverflow
Solution 1 - SqlMichael PakhantsovView Answer on Stackoverflow
Solution 2 - SqlASIK RAJA AView Answer on Stackoverflow
Solution 3 - SqlErich KitzmuellerView Answer on Stackoverflow
Solution 4 - SqlI_am_BatmanView Answer on Stackoverflow
Solution 5 - Sql2Rhino53View Answer on Stackoverflow
Solution 6 - SqlAlirezaView Answer on Stackoverflow
Solution 7 - SqlJimmyView Answer on Stackoverflow