Anto Robinson
Anto Robinson

Reputation: 463

How to extract month and year from MySQL?

Here is my query SELECT EXTRACT(YEAR_MONTH FROM <date>) FROM <table>;

Output of this query is 201309

But how to get it like Sep-2013 , and that too as a date?

Upvotes: 1

Views: 60

Answers (2)

juergen d
juergen d

Reputation: 204746

SELECT date_format(curdate(), '%b-%Y')

DATEFORMAT()

SQLFiddle demo

Upvotes: 3

Anthony
Anthony

Reputation: 37045

SELECT CONCAT(MONTHNME(<date>), "-", YEAR(<date>)  FROM <table>;

Upvotes: 2

Related Questions