SQL Query Where Date = Today Minus 7 Days

前端 未结 7 1131
花落未央
花落未央 2020-12-18 21:47

I have a SQL table of hits to my website called ExternalHits. I track the URL as URLx and the date the page was accessed as Datex. I run this query every week to get the cou

7条回答
  •  一整个雨季
    2020-12-18 22:36

    DECLARE @Daysforward int
    SELECT @Daysforward = 25 (no of days required)
    Select * from table name
    
    where CAST( columnDate AS date) < DATEADD(day,1+@Daysforward,CAST(GETDATE() AS date))
    

提交回复
热议问题