How to query for today's date and 7 days before data?

前端 未结 2 1948
借酒劲吻你
借酒劲吻你 2021-02-19 01:37

I\'m using sql server 2008. How to query out a data which is the date is today and 7 days before today ?

2条回答
  •  心在旅途
    2021-02-19 02:22

    Try this way:

    select * from tab
    where DateCol between DateAdd(DD,-7,GETDATE() ) and GETDATE() 
    

提交回复
热议问题