views:

707

answers:

3

hi, i am trying to save (using linq) the date and time to an SQL field (datetime data type) using Datetime.Now but the seconds are not coming through. Does anyone know how to rig that up?

Ta.

+2  A: 

It works fine for me with DateTime.Now. I only have problems with millisecond precision due to the different way how SQL server stores the date.

What type has the SQL table column for your date? Can it store seconds?

chris166
ive tried using smalldatetime and also datetime
Grant
SMALLDATETIME has an accuracy of 1 MINUTE. DATETIME has 3.33 milliseconds.
marc_s
+1  A: 

There is no problem with the code provided by Grant. Are you having SQLEXPRESS?

adatapost
no its the full server version
Grant
+1  A: 

As i was using a smalldatetime data field initally i forgot to update my data access layer (linq) after i changed it to datetime. Updating the linq data context has solved my problem. Thanks all.

Grant