首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL 2005 查询时间有关问题

2012-09-17 
SQL 2005 查询时间问题字段名:tempTime类型:smalldatetime值:2012-08-08 12:00:12在使用查询语句时,查询不

SQL 2005 查询时间问题
字段名:tempTime 类型:smalldatetime 值:2012-08-08 12:00:12

  在使用查询语句时,查询不出来。例:select * from temp tempTime like ('2012-08-088') .
  各种方法测试过,发现我问题出现在“-”上,各位高手,求指导^.^

[解决办法]

SQL code
select * from temp where convert(varchar(10),tempTime,120)='2012-08-08';
[解决办法]
http://msdn.microsoft.com/zh-cn/library/ms187928(v=SQL.90).aspx
[解决办法]
SQL code
declare @time date = '2012-08-08'select * from temp where tempTime > @time and tempTime >= @time <= DATEADD(DAY,1,@time) 

热点排行