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 / How to compare TWO tim...
Power Apps
Unanswered

How to compare TWO times, within an HOUR and greater than an hour.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a gallery.

In the gallery I have a label with this:

 

If(IsToday(ThisItem.'Last Assigned'),Text(ThisItem.'Last Assigned',DateTimeFormat.LongTime),"")

This produces the following:

lardo5150_0-1699299931820.png

 

I added a timer, and it runs every second.

It populates a variable.

 

Set(var_HourCheck,Now())

I then use this variable in a label to get the current time:

 

Text(var_HourCheck,DateTimeFormat.LongTime)

Which gives me this (very top above red arrow)

lardo5150_1-1699300028251.png

 

My goal is to be able to fill the label with either red or green.

I want to compare the two times.

If the time under Accept time is within an HOUR, highlight the label red.

If it is greater than an hour, highlight it green.

I really dont know how to do this and am looking for assistance.

The most I can find is to use DateDiff, but not sure how to use that in an IF statement.

Categories:
I have the same question (0)
  • SpongYe Profile Picture
    5,905 Super User 2026 Season 1 on at

    Hi @lardo5150 

     

    You code should like this:

    If(
     DateDiff(ThisItem.'Last Assigned', var_HourCheck, Minutes) <= 60, 
     RGBA(255, 0, 0, 1), // Red if within an hour
     RGBA(0, 255, 0, 1) // Green if greater than an hour
    )

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

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 395

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 287 Super User 2026 Season 1

Last 30 days Overall leaderboard