Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 past 7 days data

Author  Topic 

disha
Starting Member

34 Posts

Posted - 2007-05-24 : 12:07:49
helllo everyone,

can anyone help me with syntax for calculating past days data .

i am stuck with syntax .i need to calculate data 7 days back .

can anyone help ??

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-24 : 12:23:37
Do you have date column?

Select Col1, col2, ... from Table
Where dateadd(day, 0, datediff(day, 0, datecol)) between dateadd(day, -6, datediff(day, 0, getdate())) and dateadd(day, 0, datediff(day, 0, getdate()))


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-24 : 13:02:27
wouldn't this be simpler?

Select Col1, col2, ... from Table
Where datecol > dateadd(day, -7, datediff(day, 0, getdate))



_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-26 : 03:10:00
quote:
Originally posted by spirit1

wouldn't this be simpler?

Select Col1, col2, ... from Table
Where datecol > dateadd(day, -7, datediff(day, 0, getdate))



_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp


Yes it is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -