I have a column Month in my table. The month name and date are stored in this month column like
Month
01-JAN-12
02-FEB-12
and so on.
How do I convert the DATE into month number such as
Month
1
2
etc.
I have a column Month in my table. The month name and date are stored in this month column like
Month
01-JAN-12
02-FEB-12
and so on.
How do I convert the DATE into month number such as
Month
1
2
etc.
Use
TO_CHAR
function as inTO_CHAR(my_column, 'MM')
.For your specific format you would need the format converter
TO_CHAR(month, 'FmMM')
(thanks to Nicholas Krasnov for this trick).If your
month
column is not already of a date type you will first need to convert it to a date:TO_CHAR(TO_DATE(month, 'DD-Mon-IY'), 'FmMM')
.