Many Thanks John it works so long that both "start"
and "finish" is on the same day. There is a problem
when "start" is on 1 day and "finish" is on the next day.
Any solution please. I also wanted it to be hours so i
got it to work by divide the results by -60.
An Access Date/Time value is stored as a Double Float count of days
and fractions of a day (times) since midnight, Decmeber 30, 1899.
Therefore a time value of 6:00pm is actually stored as 0.75, and
corresponds to 6pm on December 30, 1899.
Therefore, if you have *pure time* values, 11pm is 22 hours later than
1 am; because Access considers it to be 1am on 12/30/1899, and 11pm on
12/30/1899.
You may want to use both the date and time in this field by using
Now() rather than Date() to fill it. This will make #11/12/2004
11:00pm# in fact two hours earlier than #11/13/2004 01:00am#; and
DateDiff will work as you would expect.
You can use "h" instead of "n" to get the time in integer hours. If
you need hours and fractions of an hour, you can subtract the times
and format the result using "hh:nn" as a format, or use expressions on
the minutes such as
DateDiff("n", [Start Time], [Finish Time]) \ 60 & format(DateDiff("n",
[Start Time], [Finish Time]) MOD 60, ":00")
If you want to keep the times all on December 30, 1899, and risk the
ambiguity (if the start time is 10am and the end time 11am, is that an
easy hour, or a marathon 25 hours? How can you tell?), you'll need
some IIF statements to add 24 hours if the difference is negative:
DateDiff("n", [Start Time], [Finish Time]) + IIF([Finish Time] >
[Start Time], 0, 1440)
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps