简体   繁体   English

STR_TO_DATE在mysql中进行转换

[英]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. 请解决这个问题。

尝试这个,

SELECT * FROM table_name WHERE YEAR(column_name) = 2012

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM