View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
bst bst is offline
external usenet poster
 
Posts: 19
Default calculating difference between date/time fields

?B?ZHJldw==?= wrote in
:

I am trying to count the difference between two fields which are
date/time to show if we met our service level agreements. However, I
don't want to count non business hours.

Business Hours are 8-5.

For example

Cell G3 is the date customer wants to close the deal - 6/23/2008 9:00
AM

Cell I3 is actual closing date 6/23/2008 10:45 AM

I would expect to see (1:45)

Can anyone help? Thanks!


you can use the timevalue function.

dim differenceInTime as date
with sheets("SheetName")
differenceInTime = timevalue(.range("I3").value) - timevalue(.range
("G3").value)
end with
you would need to alter the code if the it is more than a day i think.
hth
bst