1

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

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Romesh
  • 2,291
  • 3
  • 24
  • 47

2 Answers2

3

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

Himanshu
  • 31,810
  • 31
  • 111
  • 133
0

Try this:

select month(str_to_date('Mar','%b'));
Pranav Kale
  • 629
  • 1
  • 5
  • 13