SQL 2005 查询时间问题
字段名:tempTime 类型:smalldatetime 值:2012-08-08 12:00:12
在使用查询语句时,查询不出来。例:select * from temp tempTime like ('2012-08-088') .
各种方法测试过,发现我问题出现在“-”上,各位高手,求指导^.^
[解决办法]
select * from temp where convert(varchar(10),tempTime,120)='2012-08-08';
[解决办法]
http://msdn.microsoft.com/zh-cn/library/ms187928(v=SQL.90).aspx
[解决办法]
declare @time date = '2012-08-08'select * from temp where tempTime > @time and tempTime >= @time <= DATEADD(DAY,1,@time)