Skip to main content

Notifications

Community site session details
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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started
Loading started
Loading complete