如何查詢與指定日期同屬一周內(nèi)的數(shù)據(jù)

字號:

問題:
    如何查詢與指定日期同屬一周內(nèi)的數(shù)據(jù)?
    回答:
    Sql Server 中:
    與當前日期同屬一周內(nèi)的數(shù)據(jù)
    select * from 表 where datediff(week,時間字段,getdate())=0
    與指定日期同屬一周內(nèi)的數(shù)據(jù)
    select * from 表 where datediff(week,時間字段,'2002-01-01')=0
    access 中:
    與當前日期同屬一周內(nèi)的數(shù)據(jù)
    select * from 表 where datediff("ww",時間字段,date())=0
    與指定日期同屬一周內(nèi)的數(shù)據(jù)
    select * from 表 where datediff("ww",時間字段,#2002-01-01#)=0