Problem with insert dates  
Author Message
Kaos





PostPosted: Visual Basic Express Edition, Problem with insert dates Top

I have a table in sql 2005 express, this table has a datetime field. I capture the date of the server like this "05/09/2006 08:17:23 a.m.". When I try to insert this date in the datetime field of my data base, the builder show an error like there’s no possible to convert string to date time.

The insert statement is like this:

Insert into table1 (cod, date1) values (1,'05/09/2006 08:17:23 a.m')

I have a succesful insert with a date 05/09/2006 08:17:23 with out the a.m. But when I capture the date now the format is with a.m.. how can I do that



Visual Studio Express Editions24  
 
 
ahmedilyas





PostPosted: Visual Basic Express Edition, Problem with insert dates Top

to insert date/time values in SQL as you have spotted, any string format (a.m for example) will not be allowed to be inserted in SQL.

the formatting is automatically done either from the client or from the server in its representation layer, it automatically can detect what appropriate string to add at the end (a.m/p.m) since the time appears to be a 24 hour format.