STR_TO_DATE在mysql中进行转换

时间:2021-01-17 16:01:05

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.

请解决这个问题。

2 个解决方案

#1


1  

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

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

#2


2  

Try this,

尝试这个,

SELECT * FROM table_name WHERE YEAR(column_name) = 2012

#1


1  

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

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

#2


2  

Try this,

尝试这个,

SELECT * FROM table_name WHERE YEAR(column_name) = 2012