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 |
binici
Starting Member
5 Posts |
Posted - 2007-12-13 : 11:39:07
|
I have this statement that I need to execute:DELETE FROM callcenter..tRecipQueue WHERE DATEDIFF(dd, expiration_date, GetDate()) > 368Of course it doesn't work because expiration_date is a varchar data type, which contains MM/DD/YYYY value. How can I efficiently cast or convert that data, so my sp won't complain about this error?The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.The statement has been terminated.Thanks! |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-12-13 : 11:44:13
|
[code]where expiration_date >= dateadd(day, datediff(day, 0, getdate()), -368)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-14 : 03:36:47
|
1 Always use proper DATETIME datatype to store dates2 in Tan's query use where cast(expiration_date as datetime)>= dateadd(day, datediff(day, 0, getdate()), -368)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|