I have an MVC3 application in which I want to set a time interval, for example, 2 days and 5 hours. when I enter 02: 05: 00: 00, it gives me the following exception:
System.OverflowException: SqlDbType.Time overflow. Value '2.05:00:00' is out of range. Must be between 00:00:00.0000000 and 23:59:59.9999999.
When I enter at 05:00:00, it correctly stores 5 hours in the database. according to MSDN, timespan has a property for several days. How to set the days?
Model:
public class ProductionTimeVM { [Required] public TimeSpan DefaultTime { get; set; } }
In my opinion, I just use:
@Html.TextBoxFor(x => x.DefaultTime)
For my controller:
public ActionResult SaveProductionTime(ProductionTimeVM vm) { ProductionTime productionTime = new ProductionTime(); productionTime.Default = vm.DefaultTime;
Any idea?
source share