I want to store the time in a SQL Server database without seconds or milliseconds, eg 15:42:00
instead of 15:42:05.009
. However, it is stored in seconds and milliseconds. How can I remove seconds and milliseconds with getter and setter?
This is my code:
[Column(TypeName = "time")]
[DisplayFormat(DataFormatString = @"{0:hh\:mm}")]
public TimeSpan Time { get; set; }
CLARIFICATION: Through the frontend, I enter a value in the 12-hour time unit into the input, for example "12:30 ". I want to save the value coming from the frontend to the database in the same form. However, it is stored in the database with seconds and milliseconds, for example "12:30:24.0170000". I want to save the incoming value to the database without seconds and milliseconds.
P.S. That's right, I can change the display format of the same value in the database in the frontend. But I want to do everything in the backend.