Time Difference > 24 Hours

J

Jane Schuster

I need to determine the difference in hours between two events.
DateDiff("d" [CollectDate],[DueDate]) gives me the difference in days and
DateDiff("h",format(CollectDate,"hh:mm"),format(DueDate,"hh:mm")) gives me
the difference in hours, but I need to know the total hours between the two
entries.

For example: CollectDate/Time DueDate/Time DifferenceInHours
1/1/08 12:00 AM 1/3/08 12:00 AM 48 Hours (or
whatever it is)

Does anyone know the formula for returning just the hours portion of the
difference, or, in the alternative, how to convert what I have above to just
hours. Any help would be greatly appreciated.
 
P

pietlinden

Awww.... you're so close.
Get the difference in minutes, then use integer division.

DateDiff("n",StartDateTime, EndDateTime)

returns the number of minutes between the two time points. Then just
use division to get the number of hours.

DateDiff("n",StartDateTime, EndDateTime)\60 = hours only
DateDiff("n",StartDateTime, EndDateTime)/60 = hours and minutes (well,
100ths of an hour).
You could use MOD to get the remaining minutes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top