What is wrong with this calculated field for total hours between two times in SharePoint 2007?

3.6k views Asked by At

I am attempting to get the total hours between two times in a SharePoint 2007 list. Right now I have the formula as...

=INT(([Column2]-[Column1])*24)

...which I have looked up and says that it is the correct formula to do this. But, what I get is a weird date like "2/18/1900 12:00 AM" instead of what it should be: 26.

Another formula I tried was...

=TEXT([Column2]-[Column1],"h")

...but, this will only get the difference in hours and not count the days (if they are more than one apart).

Both of the columns are Date & Time columns. So, what am I doing wrong?

2

There are 2 answers

2
Christophe On BEST ANSWER

My take is that you set the output format of the calculated column to be Date and Time, while it should be of type number.

0
Paul Leigh On

In a calculated column, the number of hours between two times is:

=TEXT([Column2]-[Column1],"h")

Providing that the difference is less than 24 hours. Otherwise, you'll need to look at getting the days difference and doing a multi-step calculation involving the number of days between the dates * 24 + the calc above.