Hi All,
Dates and Times cause no end of problems.
It is possible to store them in all sorts of ways, but most people (including most questioners at Tek-Tips) store them as Date/Time types and get confused by the difference between the way the dates (and times) are stored and the ways they are formatted on input and output. An example of this is Barbara's statement that
Hours and Minutes were stored as Short Time.
For the record, Date/Time variables are stored as a number of days (e.g. 0.5 is half a day or 12 hours). Access (and the other Office applications, although they differ slightly) uses some default formatting on output which suits casual use, and allows for a variety of formatting by Users for more serious use. It also applies an amount of intelligence to interpreting input and provides a couple of conversion functions, again for more serious use.
When converted on input or output, positive values are treated as being offset from midnight (at the start of) 30 Dec 1899 (I have no idea why). Negative values can be used but there is an added complication and
for current discussion purposes it is assumed that all values are positive.
Having got a basic description out of the way, let's look at times. Times can be added and subtracted at will and the result will always be correct as a number of days. There is, however, no provision anywhere for formatting Date/Time variables as
durations rather than absolute times on absolute dates. This gives rise to two (related) problems when working with times which may be greater than 24 hours; the first (which is relatively easy to address) is getting output formatted as desired; the second (which is harder) is getting input both valid and in a format which will be understood by Access.
If all you want to do is add up individual times, each less than 24 hours, and report the total, which may be more than 24 hours then define everything as Date/Time and add them up (use DateAdd if you wish); then on output use this:
Code:
,"hh") + 24*Int(Cdbl(
If you want more, Bill's solution may do what you want, I'm not sure yet.
Bill - I have downloaded your d/b and started looking at it. I will get back to you later.
Enjoy,
Tony