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 |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2009-01-22 : 04:45:53
|
| Hi,I need to return all records where a datetime column is the date today + 7 days. Need to ignore the time part and just compare the dates.Whats best way to do this?Thank you |
|
|
karthickbabu
Posting Yak Master
151 Posts |
Posted - 2009-01-22 : 04:49:17
|
| SELECT DATEADD(DAY,7,GETDATE())==================================================== you realize you've made a mistake, take immediate steps to correct it. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-22 : 04:49:27
|
| where dateadd(dd,datediff(dd,0,createdon),0) > dateadd(dd,datediff(dd,0,dateadd(dd,7,getdate())),0) |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-22 : 04:54:06
|
| select * from urtable where dateadd(d,datediff(d,0,date),0)>=dateadd(d,datediff(d,0,getdate()),0) and dateadd(d,datediff(d,0,date),0)<=dateadd(d,datediff(d,0,getdate()+7),0)Jai Krishna |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-22 : 08:51:40
|
if you want to use index on date columnselect * from urtable where date>=dateadd(d,datediff(d,0,getdate())+7,0) and date<dateadd(d,datediff(d,0,getdate())+8,0) |
 |
|
|
|
|
|
|
|