数据库 表table 中有个日期型字段:d_date (代表一个还书时间,'2009-10-10')
我想把表中 还书时间小于当前时间的记录选择出来。
select * from table where datediff('dd',d_date,getdate())<0
这样达不到想要的效果,请大家指教下。
我想把表中 还书时间小于当前时间的记录选择出来。
select * from table where datediff('dd',d_date,getdate())<0
这样达不到想要的效果,请大家指教下。
2楼你所说的情况
多半是格式有问题
先2话不说把d_date格式化下吧
select * from table where convert(varchar(10),d_date,111)<convert(varchar(10),getdate(),111)
查了下文档aceess应该是:WHERE datediff('d',d_data,now())<=0
直接 select * from table where d_date<now()