web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Calculate hours based ...
Power Apps
Unanswered

Calculate hours based on start created date and closure date

(0) ShareShare
ReportReport
Posted on by 51

Hi,

    I have been trying to customize a SP list using power apps. In that, I want to find the aging between start and end date in terms of days and hours. I used the below formula for aging in days.

If(IsBlank(DateValue3),DateDiff(DateValue(DateValue2),Today()),DateDiff(DateValue(DateValue2),DateValue3)) where datevalue2 is created date and datevalue3 is closure date. 

 

I tried using the same formula for hours but it is not working. Could someone please tell me what formula to use?

 

PS: The dates are in the format of Date and time formats as shown in the below screenshot

JayanthanJ_0-1670238686006.png

 

 

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hi @JayanthanJ 

     

    This formula gets you a label which shows the difference between two times and displays in hours, you could modify that for your needs.

    I've attached a sample app to show you how this would work for both days and hours.

     

    If(
     IsBlank(DateValue1.SelectedDate),
     DateDiff(
     DateTime(
     Year(DateValue2.SelectedDate),
     Month(DateValue2.SelectedDate),
     Day(DateValue2.SelectedDate),
     Hour(
     DateAdd(
     Today(),
     HourValue2.Selected.Value,
     Hours
     )
     ),
     Minute(
     DateAdd(
     Today(),
     MinuteValue2.Selected.Value,
     Minutes
     )
     ),
     0
     ),
     DateTime(Year(Today()), Month(Today()),Day(Today()),Hour(Now()),Minute(Now()),0),
     Hours
     ),
     //Difference between today and today but hours are different based on selection
     DateDiff(
     DateTime(
     Year(Today()),
     Month(Today()),
     Day(Today()),
     Hour(
     DateAdd(
     Today(),
     HourValue1.Selected.Value,
     Hours
     )
     ),
     Minute(
     DateAdd(
     Today(),
     MinuteValue1.Selected.Value,
     Minutes
     )
     ),
     0
     ),
     DateTime(
     Year(Today()),
     Month(Today()),
     Day(Today()),
     Hour(
     DateAdd(
     Today(),
     HourValue2.Selected.Value,
     Hours
     )
     ),
     Minute(
     DateAdd(
     Today(),
     MinuteValue2.Selected.Value,
     Minutes
     )
     ),
     0
     ),
     Hours
     )
    ) & " Hours"

     

    Cheers,

    Sancho

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 474

#1
Valantis Profile Picture

Valantis 474

#3
WarrenBelz Profile Picture

WarrenBelz 375 Most Valuable Professional

Last 30 days Overall leaderboard