Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use SQL Server time datatype in C#.NET application?

How does one use the SQL time datatype introduced in SQL Server 2008 in C#.NET?

I've been trying to get it to work but no success.

like image 376
rdk Avatar asked Mar 14 '11 16:03

rdk


People also ask

How can use time datatype in SQL Server?

The seconds and fractional seconds are set to 0. The following code shows the results of converting a time(4) value to a smalldatetime value. If the conversion is to datetimeoffset(n), the date is set to '1900-01-01', and the time is copied. The time zone offset is set to +00:00.

What is the datatype for time?

The DATETIME data type stores an instant in time expressed as a calendar date and time of day. You select how precisely a DATETIME value is stored; its precision can range from a year to a fraction of a second.


1 Answers

Here is an MSDN article that reviews all the new Date and Time datatypes introduced in SQL Server 2008 with respect to ADO.NET. As the document says: For System.Data.DbType.Time you would use the .NET Framework type System.TimeSpan

like image 102
Simen S Avatar answered Sep 21 '22 14:09

Simen S