SoManyQuestions
SoManyQuestions

Reputation: 33

Mysql using monthname with month

I'm trying to get the name of the Month through Monthname, but it just returns (NULL)

Date = 4

MONTHNAME(str_to_date(Month(Date), '%m'))

Upvotes: 2

Views: 521

Answers (2)

Emanuel Pirovano
Emanuel Pirovano

Reputation: 236

Try this:

SELECT MONTHNAME(STR_TO_DATE(1, '%m'));//returns January

Also read this Documentation

Upvotes: 1

Darshan Mehta
Darshan Mehta

Reputation: 30819

As per MySQL's documentation, you can use MONTHNAME function directly on date column, e.g.:

SELECT MONTHNAME(Date);

This would give you the required result.

Upvotes: 2

Related Questions