Pergunta

I am searching for a built-in function in MySQL for getting Month Number for given Month Short Name like 'Jan','jul',etc.

Foi útil?

Solução

Use STR_TO_DATE() function to convert String to Date like this:

SELECT STR_TO_DATE('Apr','%b')

And use MONTH() to get month number from the date like this:

SELECT MONTH(STR_TO_DATE('Apr','%b'))

See this SQLFiddle

Outras dicas

Try this:

select month(str_to_date('Mar','%b'));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top