Reputation: 60861
I would like to know how to insert TIME into SQL Server using C#
I have a class that I use as a data layer:
public class Main_Lom_Form
{
public string Specimen_ID
public int Client_Key
public string Outcome
public string Medications
public DateTime Date_Collected
public DateTime Time_Collected
and I do not know if I should be declaring Time_Collected
as DateTime?
What type should Time_Collected
be so that if the time would be 13:05
it would be entered correctly into a column in SQL Server 2008 that is a TIME(7)
datatype?
Upvotes: 2
Views: 4632
Reputation: 51664
TimeSpan
maps to time(7)
DateTime
maps to datetime
If you only want to store time, then time(7)
should be okay. Is there a reason why you don't combine Date_Collected
and Time_Collected
into one field of type datetime
?
Upvotes: 6