Forum Discussion
Duration Field for SharePoint List - Event Itinerary Template
**Edited - Had to update as I found an issue with half hour treatment in the first version**
I decided to use the Event Itinerary List template that's in the Microsoft Template library for SharePoint lists. I really liked the way the Duration calculation worked to show Hours and Minutes in this template so kudos to the developer. For the most part, it also works really well when bringing through Start and End Times (with Time zones) from Outlook when using this SharePoint List with a Power Automate integration.
However, I'm "down under" so because of my time zone, the Duration calculation doesn't like times that go over midnight UTC. It's like the rounding drops a fraction of a second, so it drops below the parameters of the calculation. As in, the Duration calculation in this template rounds down any duration that goes over the UTC midnight. This happens to be 11am in Sydney 😢, so a lot of meetings were having incorrect Duration calculations.
Why? It's all because the calculation uses the INT function. This truncates rather than Rounds the number. So a meeting that goes from 10:30am to 11:30am has a duration something like 0.9999999999. Because of the INT function, this becomes 0 hours.
So if you are stuck like I was, you can add an extra column and reference that in the Duration calculation to make this clean. To do that:
Create a new calculation field by going to the cog settings on the List and picking List Settings from the menu:
Half way down the page, there should be the Create Column. Click on that to open the create column window:
Select the Calculated option:
And then scroll down to the calculation field and enter the following calculation in that field, make sure it is set to Single line of Text and click OK:
Here is the calculation (you will need to change the 2 if you want to have very precise times to the minute, but this will work fine with 15 minute increments):
=ROUND(([End date and time]-[Start date and time])*24,2)
Then change the Duration calculation by selecting that field:
In the formula field, you'll have the previous formula (you can see the 'INT' function still there that we are about to replace):
Clear that content and replace with the formula provided below for copying. Click "Ok" to complete the update. Note, this only works for hours and minutes, so best used with meeting calendar rather than multi-day durations:
=CONCATENATE(IF(INT([Hour Calculation])>0,CONCATENATE(INT([Hour Calculation])," ",IF(INT([Hour Calculation])>1,"hours","hour")),""),IF(MINUTE([End date and time]-[Start date and time])>0,CONCATENATE(" ",MINUTE([End date and time]-[Start date and time])," ",IF(MINUTE([End date and time]-[Start date and time])>1,"minutes","minute")),""))
Go back to your SharePoint List and refresh the browser window. You should have the Duration update correctly now.