SQL server date error
-
12-10-2019 - |
Question
UPDATE tblCampaigns SET startDate = '4 December, 2010', endDate = '14 January, 2011' WHERE ID = 147
UPDATE tblCampaigns SET startDate = '24 December, 2010', endDate = '17 Febuary, 2011' WHERE parentID = 147 and campaignName = 'regerg'
Microsoft OLE DB Provider for SQL Server error '80040e07'
Syntax error converting datetime from character string.
/bb/campaignManager/index.asp, line 147
These work when the dates are 2010 but as soon as a 2011 is put in there it goes wrong, any ideas? It's probably in the wrong format right?
Solution
It's "February", not "Febuary"
OTHER TIPS
I wouldn't ever do that: if the default date format in your database changes, then you're scuppered. Instead, always cast strings to dates explicitly, so you retain control:
UPDATE tblCampaigns SET startDate = convert(datetime, '20101204', 112)
http://msdn.microsoft.com/en-us/library/aa226054(v=SQL.80).aspx
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow