sql server:
select * from 表 where 发生日期>'2008-7-1' and 发生日期<'2008-12-31'
access:
select * from 表 where 发生日期>#2008-7-1# and 发生日期<#2008-12-31#
这样就可以了,注意sql server与access中的日期有一点不一样。
sql查询日期语句
select * from ShopOrder where datediff(week,ordTime,getdate()-1)=0 //查询当天日期在一周年的数据
select * from ShopOrder where datediff(day,ordTime,getdate()-1)=0 //查询当天的所有数据
SELECT * FROM A where datediff(d,datetime,getdate()) <=30 //前30天
SELECT * FROM A WHERE DATEDIFF(m, shijian, GETDATE()) <=1 // 上一月
查询当天记录另类的方法:
SELECT *
FROM j_GradeShop
WHERE (GAddTime BETWEEN CONVERT(datetime, LEFT(GETDATE(), 10) + ' 00:00:00.000')
AND CONVERT(datetime, LEFT(GETDATE(), 10) + ' 00:00:00.000') + 1)
ORDER BY GAddTime DESC