Reputation: 188
Hi all I am very new to mysql statement I just wondering how do we convert and get only Abbreviated month name to number with single code Example String "2008Jan20" to 2008-01-20 Then get only month 01
MONTH(STR_TO_DATE(6, '%m'));
Upvotes: 1
Views: 940
Reputation: 6661
use str_to_date
converts the string into a date value based on the format string
str_to_date('2008Jan20','%Y%b%d')
Get month number
Month(str_to_date('2008Jan20','%Y%b%d')) //get month number
Get MONTHNAME
MONTHNAME(str_to_date('2008Jan20','%Y%b%d')) //get month name
Upvotes: 1