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

前端 未结 2 1946
借酒劲吻你
借酒劲吻你 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:33

    Query in Parado's answer is correct, if you want to use MySql too instead GETDATE() you must use (because you've tagged this question with Sql server and Mysql):

    select * from tab
    where DateCol between affffdate(now(),-7) and now() 
    

提交回复
热议问题