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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-07 : 09:59:00
|
| Pooja writes "Hey Guys,I was trying to write a SQL query which would select a record based on how long ago was it entered.for example.Say You placed your order on july 15th 06, now the table has an order date which says 20060715 or something like that, not i want to write a statement which will only select that order (based on orderid) if that date is less than 15 days old.so say if i run the query today (08-22-06) then i should not get that orderid... but if i had run it on the 16th of july it should have come up...been searching for it all day cant find itthanks in advancePooja" |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-09-07 : 10:43:14
|
| Here is one way (that assumes your order_date column is either datetime or smalldatetime)where order_date >= dateadd(day, datediff(day, 15, getdate()), 0)Be One with the OptimizerTG |
 |
|
|
|
|
|