function udf with date and time

  • Thread starter Thread starter 1234
  • Start date Start date
1

1234

Hi,

How can I program a udf function that counts the hours between two
times knowing that they can occur on the same day or in several days.
Example:

Start 1/1/2009 10:30
End 1/2/2009 9:30

The function should calculate 23 hours, also minutes

Thanks guys
 
Do you really need a UDF for that? If the start date and time is in A1
and B1 and the end date and time in A2 and B2, then the following will
give you the elapsed (decimal) hours:

=(A2-A1+B1-B2)*24

Format the cell as number with 2dp. Note that an answer of 16.25, for
example, will mean 16 hours and 15 minutes.

Hope this helps.

Pete
 
Sorry, I can see that I have got that a bit mixed up. It should be
this:

=(A2-A1+B2-B1)*24

Hope this helps.

Pete
 
Back
Top