Showing results for 
Search instead for 
Did you mean: 
Post Patron
Post Patron

Combining time intervals


I have a DateTime filed in my app with the name Downtimes and sum of all this downtimes.I  want to combine same intervals with different reasons.

For example:

IT Downtime from 5:00 to 7:00 - 2 hours

Maintenance Downtime from 6:00 to 8:00 - 2 hours

Now Sum of Downtime Time is 4 hours. And I want it to be 3 hours because from 6 to 7 hour is the same interval.

How I can make it in PowerApps?

Super User
Super User


You could simply take the second date/time from the second downtime and the first date/time from the first downtime, and use DateDiff function


DateDiff( StartDateTime, EndDateTime, Hours )



 In order to know if the second interval overlaps with the first interval - this may not matter. Instead,  use the If function to determine if the difference is negative - if it is negative, then they do not overlap and in that case you need to take both intervals


DateDiff( StartDateTime, EndDateTime, Hours ) + DateDiff( StartDateTime, EndDateTime, Hours )



Otherwise, if they do overlap, or in other words, if the next interval's end date/time is sometime after the previous one's end date/time you just do the simple one where you take the EndDateTime of the second interval and subtract it from the StartDateTime of the first interval:


DateDiff( StartDateTime, EndDateTime, Hours )



Check if the above approach helps as a starting point.

If you want to be able to do this for any "N" number of intervals in a seamless way, you'll need to do a bit more than the above. Check if the above helps as starting point and if not, you can try to post here and I might see if I have time to check again for a more seamless solution for you.

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.


New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,487)