Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 TableWhere dateadd(day, 0, datediff(day, 0, datecol)) between dateadd(day, -6, datediff(day, 0, getdate())) and dateadd(day, 0, datediff(day, 0, getdate()))
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
spirit1
Cybernetic Yak Master
11752 Posts
Posted - 2007-05-24 : 13:02:27
wouldn't this be simpler?Select Col1, col2, ... from TableWhere datecol > dateadd(day, -7, datediff(day, 0, getdate))_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
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 TableWhere datecol > dateadd(day, -7, datediff(day, 0, getdate))_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp
Yes it is MadhivananFailing to plan is Planning to fail