Q:

Extract Month from date as number

I have a query that accepts the date in the following format:
'31 AUG 2012'
I need the query to return the month as a number.  For the above date, the returned value would be 08
I have tried the following:
EXTRACT(MONTH FROM DATE '31 AUG 2012')
TO_DATE('31 AUG 2012', 'MM')
TO_CHAR('31 AUG 2012', 'MM')

All of which give me the below errors respectively:
ORA-01861: literal does not match format string
ORA-01843: not a valid month
ORA-01722: invalid number
How can this be accomplished?  Thanks

A:

SELECT EXTRACT(MONTH FROM date '2012-08-31') FROM dual;

