初学SQL,问个根据日期查询的问题?
记录如下:
khzj khsj
16 2012-01-26 23:11:18.280
17 2012-01-26 23:11:21.750
18 2012-01-26 23:11:25.187
19 2012-01-26 23:11:31.233
20 2012-01-26 23:11:34.937
21 2012-01-26 23:11:38.123
22 2012-01-27 14:26:48.500
23 2012-01-27 14:28:51.967
24 2012-01-27 14:32:05.890
25 2012-01-27 14:33:47.373
26 2012-01-27 14:36:15.343
-------------------------
我想查询当日的记录,用GETDATE()什么也查不出来
select * from t where khsj=getdate()
改怎样写才能查出当日的记录呢?
------解决方案--------------------
SQL code
select *
from t
where datediff(day,khsj,getdate())=0