Lill Lansey Lill Lansey - 4 years ago 161
C# Question

Does SqlDbType.DateTime not store seconds?

using System.Data;
using System.Data.SqlClient;

I am using a
SqlCommand cmd.Parameters
to create a record in the database.

Seconds are not being stored in the database. The field in the db is of type datetime.

Do I need to do something special to save seconds, or does
not do that?

Answer Source

SqlDbType.DateTime maps to SQL's DATETIME datatype, which is accurate to 3.33 milliseconds. It sounds like you may be putting your values into a SMALLDATETIME field in SQL server, which is only accurate to the minute. SqlDbType.DateTime parameter would be the correct choice for use with both DATETIME and SMALLDATETIME.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download