I have a web form that has a dropdownlist with hh:mm tt with 30 minutes interval, starting from 6:00am, 6:30 am, 7:00am....8:00pm. How can I save selected time to MS Sql. I am not sure what datatype (Date, DateTime, Time(7) in Microsoft SQL I should use. Please help me advise. This is my c# code to define hh:mm tt and load on the form.
private void AddDropDownValues(ref DropDownList ddlHrMin, int startHour, int endHour, int increment)
{
DateTime now = DateTime.Now;
DateTime startTime = new DateTime(now.Year, now.Month, now.Day, startHour, 0, 0);
DateTime endTime = new DateTime(now.Year, now.Month, now.Day, endHour, 0, 0);
while (startTime <= endTime)
{
ddlHrMin.Items.Add(startTime.ToShortTimeString());
startTime = startTime.AddMinutes(increment);
}
}
protected void Page_Load(object sender, EventArgs e)
{
AddDropDownValues(ref ddlHrMin, 6, 20, 30);
}