function udf with date and time

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
 
P

Pete_UK

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
 
P

Pete_UK

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
 

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

Top