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 betwee...
Power Apps
Answered

calculate hours between two dates in text format

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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. 

Categories:
I have the same question (0)
  • EdViegas Profile Picture
    436 on at

    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
    )

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    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.

  • EdViegas Profile Picture
    436 on at

    Don't forget RoundUp

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @madcoderz,

    Have you resolved your problem?

    If your issue is still, share the details.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard