Skip to main content
Community site session details

Community site session details

Session Id : QM0zxUDXHIkqvWc6PelkXX
Power Apps - Building Power Apps
Answered

calculate hours between two dates in text format

Like (0) ShareShare
ReportReport
Posted on 2 Apr 2022 08:28:54 by

Hi everybody. I need to calculate hours between two dates from a text label. What i tried is giving me 6 hours as a result.

Here´s what i spect: 

StartDate: 20/02/2022 23:00

EndDate:  21/02/2022 04:30

Total Hours: 5 hours

 

This is what i tried:

"Total Hours: " & DateDiff(DateTimeValue(start_date_label.Text); DateTimeValue(end_date_label.Text);Hours)

Any help will be much appreciated. 

  • v-qiaqi@microsoft.com Profile Picture
    on 15 Apr 2022 at 07:34:05
    Re: calculate hours between two dates in text format

    Hi @madcoderz,

    Have you resolved your problem?

    If your issue is still, share the details.

  • EdViegas Profile Picture
    436 on 05 Apr 2022 at 15:37:53
    Re: calculate hours between two dates in text format

    Don't forget RoundUp

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    on 05 Apr 2022 at 04:52:09
    Re: calculate hours between two dates in text format

    Hi @madcoderz,

    Here is what I achieve on my side:

    vqiaqimsft_0-1649134272143.png

    vqiaqimsft_1-1649134288599.png

     

    I will suggest you use a Date time picker to display date time value.

  • Community Power Platform Member Profile Picture
    on 02 Apr 2022 at 20:43:29
    Re: calculate hours between two dates in text format

    Thanks for the answer but the result is also wrong. Is giving 7 hours when it should be 5 hours. 

  • EdViegas Profile Picture
    436 on 02 Apr 2022 at 10:10:57
    Re: calculate hours between two dates in text format

    TextInput1: "01 Mar 2022 11:00 PM"

    TextInput1_1: "02 Mar 2022 04:30 AM"

    Label: Total hours: 6

     

    "Total Hours: " & RoundUp(
     DateDiff(
     DateTimeValue(TextInput1.Text),
     DateTimeValue(TextInput1_1.Text),
     Minutes
     ) / 60,
     0
    )

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Loading complete