Hi, I have a list with 2 columns (Start Time, End Time) that contains
date & time information and a third column (Duration) that is
calculated field. I wanted to calculate the difference between the
first 2 columns and show it in the 3rd field. It's working fine, but
in some cases, the result is incorrect. Below are the details:
I wanted to show the Duration column values like "2 hours 45 minutes". If it's 0 minutes, then just show "2 hours". The complete formula I used is:
=CONCATENATE(IF(INT(([End Time]-[Start Time])*24)>1,INT(([End Time]-[Start Time])*24)&" hours",IF(INT(([End Time]-[Start Time])*24)=1,INT(([End Time]-[Start Time])*24)&" hour","")),IF(MINUTE([End Time]-[Start Time])>0,MINUTE([End Time]-[Start Time])&" minutes",""))
In the above formula the part that calculates the hour difference is:
INT(([End Time]-[Start Time])*24)
If the start time is at 9:00am and the end time is at 1:00pm, the result is 3 hours although it should be 4 hours. If the start time is 10:00am and end time is 1:00pm, the result is 3 hours, which is right. But if the start time is 11:00am and end time is 1:00pm, the result is 1 hour, but it should be 2 hours. Also, if the start time is 12:00pm and the end time is 1:00pm, the result is 0 hours. Interestingly, if the start time is 9:00am and the end time is 1:05pm, the result is 4 hours.
Below is a table where I've put all my sample data and you can see that some results are correct, but where I have end time is 1:00pm, sometimes it's incorrect. Just compare the result of the last 4 rows with. The last row's Duration is empty because the calculation result is 0 hour.
Can you shed any light on this? Is it a bug in sharepoint or is it the formula that I am using? Is there any simpler formula than the one I'm using but will give me the same result?
I wanted to show the Duration column values like "2 hours 45 minutes". If it's 0 minutes, then just show "2 hours". The complete formula I used is:
=CONCATENATE(IF(INT(([End Time]-[Start Time])*24)>1,INT(([End Time]-[Start Time])*24)&" hours",IF(INT(([End Time]-[Start Time])*24)=1,INT(([End Time]-[Start Time])*24)&" hour","")),IF(MINUTE([End Time]-[Start Time])>0,MINUTE([End Time]-[Start Time])&" minutes",""))
In the above formula the part that calculates the hour difference is:
INT(([End Time]-[Start Time])*24)
If the start time is at 9:00am and the end time is at 1:00pm, the result is 3 hours although it should be 4 hours. If the start time is 10:00am and end time is 1:00pm, the result is 3 hours, which is right. But if the start time is 11:00am and end time is 1:00pm, the result is 1 hour, but it should be 2 hours. Also, if the start time is 12:00pm and the end time is 1:00pm, the result is 0 hours. Interestingly, if the start time is 9:00am and the end time is 1:05pm, the result is 4 hours.
Below is a table where I've put all my sample data and you can see that some results are correct, but where I have end time is 1:00pm, sometimes it's incorrect. Just compare the result of the last 4 rows with. The last row's Duration is empty because the calculation result is 0 hour.
Can you shed any light on this? Is it a bug in sharepoint or is it the formula that I am using? Is there any simpler formula than the one I'm using but will give me the same result?
Start Time |
End Time |
Duration |
1/24/2009 7:00 AM |
1/24/2009 3:00 PM |
8 hours |
1/24/2009 8:00 AM |
1/24/2009 6:00 PM |
9 hours |
1/25/2009 6:00 AM |
1/25/2009 8:00 PM |
14 hours |
2/7/2009 8:00 AM |
2/8/2009 5:35 PM |
33 hours 35 minutes |
2/8/2009 7:00 AM |
2/9/2009 5:00 PM |
34 hours |
2/10/2009 8:00 AM |
2/10/2009 8:30 AM |
30 minutes |
2/8/2009 9:00 AM |
2/8/2009 1:00 PM |
3 hours |
2/11/2009 10:00 AM |
2/11/2009 1:00 PM |
3 hours |
2/14/2009 11:00 AM |
2/11/2009 1:00 PM |
1 hour |
2/16/2009 12:00 PM |
2/16/2009 1:00 PM |