| Author |
Topic |
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2009-02-20 : 15:54:38
|
Hi Group:Need a little help selecting 14 days in the past. GETDATE (-14 DAYS)HELP THANKS!!!!!!! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2009-02-20 : 15:59:40
|
| Thank you tkizer :) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-02-21 : 03:51:15
|
| WHERE DATEDIFF(d,colname,getdate())<=14Jai Krishna |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-02-21 : 04:01:26
|
quote: Originally posted by Jai Krishna WHERE DATEDIFF(d,colname,getdate())<=14Jai Krishna
May not use the index if it is defined for date columnMadhivananFailing to plan is Planning to fail |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-21 : 08:42:31
|
| DATEADD(day,-14,getdate()) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2009-02-22 : 09:24:23
|
| i would use something like:where somedate >= cast(convert(varchar(11), getdate()-14, 121) as smalldatetime)instead of only where somedate >= getdate()-14because the first one neglect the time, which is probably what you need, when you want to browse 14 days in past? if you use only getdate()-14 this take into consideration time (hours:minutes), and if you run second condition twice within a minute, you might get different results. |
 |
|
|
|