I want to ask something rather simple.
I am creating a client sever aplication and at some cases I want to save at sql server a time (12:00 or 17:15 for example).
It will be a problem to save at a datetime field of a table only the time (giving the format 10:00 AM for example) or I have to give at a datepicker for example the format to show only time and not all date?
What is the best?
I see nothign wrong sith simply storing the time value in a datetime field, but you must realise that you do technically still get a date part, but this is equivalent to 0.
In terms of SQL Server, the base date (or 0) is 1900-01-01 00:00:00.000
To check this out run the following
there are time durations (e.g. roger bannister, 3:59.4) and there are times of day (e.g. 9:37 a.m.)
if you are dealing with durations (e.g. what is your average time over your last three races) then i would use DATETIME simply because you can use date arithmetic functions
if you are dealing with times of day (e.g. what time does the park close) then i might use VARCHAR simply because this allows values like dusk or noon (the former being desirably imprecise and the latter unambiguous as to which 12:00 it's referring to)