How should a time period be represented in SQL?
I am using ASP.NET MVC4 and SQL Server 2008.
I have a business requirement that requires equipment to be serviced X times. Different items of equipment require different amounts of time before service.
In the database, I need to store the period in which the equipment needs to be serviced, as well as the next service date.
On the hardware edit screen, I need a dropdown with options to allow the user to select ServiceInterval . It would be preferable not to have a fixed dropdown over time, but I'm not sure how to do this.
- 3 months
- 6 months
- 9 months
- 1 year
- 1.5 years
- 2 years
- 3 years
- 4 years
- 5 years
By clicking on the "Serviced" button, add the ServiceInterval to the current date and place it in the NextServiceDue field .
What is the best way to store this information, and is there a good way to do it?
Thanks, Mike
source to share
It depends on what level of detail you want, but you are creating a table in the database with a name and number of seconds or days.
From there, when the user selects an item, just a date DateTime.Now.AddDays(userInput);
or DateTime.Now.AddSeconds(userInput);
. You can also save the interval period along with the healthy item.
source to share