mysql,查询日期是2012-1-1的数据,sql怎么写

表里有个datetime类型的字段
我要查询日期是2012-1-1的数据
sql语句里,where条件怎么写

使用date_format将表中datetime字段的值转换成“年月日”格式的字符串即可
语句这样写:
select * from 表名 where date_format(日期字段,'%Y-%m-%d') = ‘2012-1-1’;

记得采纳。
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-11-14
列名=‘2012-1-1’ 如果你数据库里存的是时间戳列名=时间戳
第2个回答  2012-11-14
datetime='2012-1-1'
第3个回答  2012-11-14
select * from tb where day like '2012-1-1%' ;
相似回答