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 - 2007-08-23 : 12:32:15
|
| A have this where clauseWHERE updated >= '2007/16/8'This gives me all records within the last 7 days - fine.But I want to exclude records where the updated and created date are the same.WHERE updated >= '2007/16/8' AND Updated <> CreatedThis doesn't work, the same records as the first query are returned.The updated and created columns are both datetime, do I need to specify that I only want to compare the date portion? If so how do I do this?Thanks |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-08-23 : 12:38:36
|
| WHERE updated >= dateadd(dd,DATEDIFF(dd,0,'2007/8/16')and dateadd(dd,DATEDIFF(dd,0,updated)<> dateadd(dd,DATEDIFF(dd,0,created)Jim |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-23 : 12:55:12
|
Hopefully UPDATED is always greater than or equal to CREATED. Never less than.WHERE updated >= '200708016'and DATEDIFF(dd,created, updated) > 0but if it is not...WHERE updated >= '200708016'and DATEDIFF(dd,created, updated) <> 0 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|
|
|