Quote:
I read about ISO 8601 dates, but when I tried to use the following Sql
statement:
string cmd = string.Format("UPDATE myTable1 SET datetime1 = '{0}'",
myLocalDate.ToString("yyyy-MM-ddTHH:mm:ss.fffff",
CultureInfo.InvariantCulture));
I'm getting an error on sql server about bad format of char trying to cast
to datetime !!??
What am I doing wrong ?
I don't know what are you doing wrong, but a locale-independent date format
|
(iso 8601 is perfect) is the right thing to do.
Maybe you also have to configure the sql server to accept dates in that
format?
You might want to check if the SQL server has something like
SET DateStyle TO 'ISO' (PostgreSQL)
MS SQL 2000 (I don't know about newer versions) did not directly
support ISO 8601, but you could use SET DATEFORMAT MDY and it would
accept the string you are building (YYYY-MM-DDTHH:MM:SS.fff)
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email