Groups | Blog | Home
all groups > sql server programming > august 2004 >

sql server programming : DateTime format during INSERT


David Portas
8/15/2004 9:39:48 PM
Use one of the following string formats, which should be interpreted
correctly regardless of regional date settings:

'20031231' -- Just the date
'2003-12-31T17:59:00' -- Date/hours/minutes/seconds
'2003-12-31T17:59:00.000' -- Date/hours/minutes/seconds/milliseconds

--
David Portas
SQL Server MVP
--

Tim
8/15/2004 10:21:01 PM
Hi,

The date format of the SQL Server causes me some trouble at the moment:
My INSERT statement uses DateTime values of the format "yyyy-mm-dd
hh:mm:ss.mmm" but they somehow get interpreted as"yyyy-dd-mm" causing a date
format out of range exception.

How can I "force" SQL Server to use my date format? Calling "SET DATEFORMAT
YMD" on each open connection before the statement is executed does not help
but this may be caused by additional connections being opened "behind the
scenes" (so I've been told).

The db-user opening the connection has the correct language setting and the
collation label of the databases is also correct.

So I'm wondering whether it's the regional setting of the Windows account
that runs the SQLServer-service (or SQLSERVERAGENT-Service?) that causes
this? But then - what region would use "yyyy-dd-mm" as it's date format?

- Tim

AddThis Social Bookmark Button