arsal
arsal

Reputation: 23

STR_TO_DATE Conversion in mysql

I made this query which select the date in column, now i want to get the year only from selected date .

SELECT column_Name
FROM table_name
WHERE column_name = STR_TO_DATE( '00/00/0000', '%m/%d/%Y' )

Please solve this problem.

Upvotes: 1

Views: 171

Answers (2)

chhameed
chhameed

Reputation: 4446

The ans of this unclear question should be

SELECT YEAR(STR_TO_DATE( '00/00/0000', '%m/%d/%Y' )) as date from table_name

you should get help fron it

http://dev.mysql.com/doc/refman/5.0/en/date-calculations.html

Upvotes: 1

GoSmash
GoSmash

Reputation: 1108

Try this,

SELECT * FROM table_name WHERE YEAR(column_name) = 2012

Upvotes: 2

Related Questions