C# – What are equivalent C# data types for SQL Server’s date, time and datetimeoffset


What are the most suitable equivalent C# data types for the date datatypes in SQL Server? I'm specifically looking for

  • date
  • time
  • datetimeoffset

Best Solution

Here are the equivalent CLR data types for date, time and datetimeoffset SQL Server data types:

date - DateTime, Nullable<DateTime>
time - TimeSpan, Nullable<TimeSpan>
datetimeoffset - DateTimeOffset, Nullable<DateTimeOffset>

Note that you can find a listing of all SQL Server data types and their CLR equivalents here, Mapping CLR Parameter Data