?:我在SQL SERVER 2000中有个字段,是datetime型的,里面的数据格式如:2005-11-12 14:30:51 现在我想按年月日查询,比如查询所有2005-11-12 的信息,这个查询语句该如何写呢? 谢谢前辈们指点,谢谢
>>select * from table where datediff(dd,date,'2005-11-12')=0
>>declare @date datetime set @date='2005-11-12' select * from 表 where datediff(day,字段,@date)=0 --or --select * from 表 where convert(char(10),字段,120)=convert(char(10),@date,120)
>>谢谢前辈们
>>select * from where convert(char(10),Time,20)='"+TextBox1.Text.Trim().ToString; convert(char(10),Time,20) 输出的时间格式是YYYY-MM-DD
(编辑:网站学习网)
|