Hi,
Can anyone suggest the best way of storing a time value.
I have a simple db table and need to track time taken on a particular job -
if I choose Date/Time seems ok until a job takes more than 24 hrs.
Access Date/Time values are best used for storing specific points in time.
Internally they're stored as a Double Float number, a count of days and
fractions of a day since midnight, December 30, 1899. As such, a time value of
27 hours 30 minutes actually corresponds to #12/31/1899 03:30:00AM#; and there
is no format (as there is in Excel, say) to display this as 27:30.
Your best bet is to not store durations in a Date/Time field at all. You can
store start time (e.g. #4/29/2009 11:30AM#) and end time (#4/30/2009
08:45AM#), and then use DateDiff("n", [StartTime], [EndTime]) to get the time
elapsed in minutes. These integer minutes can be summed, averaged, etc. just
like any other number. To display the elapsed time you can use an expression
like
ShowTime: [elapsed] \ 60 & Format([elapsed] MOD 60, "\:00")
The \ isn't a typo, it's an integer divide operator.