什么时候输入的你都不知道,怎么提啊?
要么这样:
SET DATEFIRST 1
--设置每周开始为周一,默认老美是周日.--
select * from tablename where DATEPART(dw,YourDateField)<=DATEPART(dw,getDate()) and datediff(d,inputdate,getdate())<7
--取出输入时间距现在为一星期以内且周的日子不大于当前时间对应周的日子--
什么时候输入的你都不知道,怎么提啊?
SET DATEFIRST 1
select * from tablename where DATEPART(dw,YourDateField)<DATEPART(dw,getDate()) and datediff(d,inputdate,getdate())<7