一个困扰我的问题,mysql的时间问题。

一个表(thinker)有一下内容
t_id t_title t_date
1 one joke 2002-8-23 12:00:04
2 two jokes 2002-8-23 13:12:12
3 three jokes 2002-8-23 14:15:12
查询:SELECT date_format(t_date,"%Y-%m-%d") FROM thinker
结果:
2002-8-23
2002-8-23
2002-8-23
又:SELECT * FROM thinker WHERE date_format(t_date,"%Y-%m-%d")='2002-8-23'
显示为empty set,空集

我的意图就是找出时间为2002-8-23的内容,可能我的方法不对,请指教!

---------------------------------------------------------------

SELECT * FROM thinker WHERE left(t_date,10)='2002-08-23'

如果是datetime格式,月份和日期应该都是两位

---------------------------------------------------------------

SELECT * FROM thinker WHERE to_days(t_date)=to_days('2002-8-23')

Published At
Categories with Web编程
comments powered by Disqus