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 |
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2013-09-01 : 15:27:45
|
DECLARE @datefrom DateTime SET @datefrom = '30/11/2013 00:00:00' SELECT [events].datefrom, [events].*FROM [events] WHERE [events].live > 0 AND [events].deleted < 1AND (@datefrom <= datefrom OR @datefrom is null OR @datefrom = '')WHEN running this in SQL, this flashes a list of the events with the date filter then reports:The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.(852 row(s) affected).I'm confused, I don't know what is going on?I got the '30/11/2013 00:00:00' from .net datetime SQL parameter type |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2013-09-01 : 17:07:15
|
Use:SET @datefrom = convert(datetime,'2013-11-30 00:00:00',120)or:SET @datefrom = cast('2013-11-30 00:00:00' as datetime) |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-09-01 : 21:59:55
|
best is simply specify the date in ISO formatSET @datefrom = '2013-11-30' KH[spoiler]Time is always against us[/spoiler] |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
|
|
|