Hi,
I'm a newbee to SQL Server. I have a very simple question to you experts: How should I code a literal of the "datetime"-Datatype For Example in the VALUES-clause of an SQL-statement. I have tested several "formats" ('20.04.2006 11:15:00' with an 4-digit year enclosed in single apostrophes) but all i earned is an exception!
Any help very appreciated!
Thanks in advance and best regards
Reiner
PS.: I'm using a german-localized database (thus the date-format dd.MM.yyyy).

How to code DateTime-Literal in SQL Server
ciroma
redbeans
You are doing the right thing, dates in SQL are inclosed by single '. Are your clients localized with the same culture as the database Is so you should be able to
strsql = "INSERT INTO TABLE VALUES('" & datetime.tostring() & "')"
and the tostring method with format it properly.
Also try it with - instead of . in the date.
What I would do is open SQL Query Analyzer and write out the SQL insert query with a date and keep modifying the date format until it accepts it.
If none of this is a help then post the exception message.
MkmEV
Look up date and time formats in books online. There are some ISO date time formates that are the best practice. Generally speaking, the formats are:
YYYYMMDD or YYYY-MM-DD
then time:
HH:MM:SS.SSS
There are variations, but the most important bits have to do with the year month date arrangement that is not ambiguous in any country