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 / label based on time
Power Apps
Answered

label based on time

(0) ShareShare
ReportReport
Posted on by 141

Hello everyone,

 

How is it best to show a label based on time.

The label must be displayed every day from 11:00 am to 2:00 pm

 

Best regards, Raymond van der Horst

Categories:
I have the same question (0)
  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    In the Visible property of the label, paste this code:

    If(
     DateDiff(Today(),Now(),Hours) >= 11 && DateDiff(Today(),Now(),Hours) < 14, 
     true, 
     false
    )

    This will use the user's local time zone to determine 11am and 2pm.

     

    Hope that helps,

    Bryan

  • rho1967 Profile Picture
    141 on at

    Many Thanks BCLS776

     

     

  • rho1967 Profile Picture
    141 on at

    Only one question Bryan,

     

    Is this also possible with minutes. example 16:15 until 17:02?

     

    Regards,

    Raymond

     

  • BCLS776 Profile Picture
    8,994 Moderator on at

    @rho1967 wrote:

    Only one question Bryan,

     

    Is this also possible with minutes. example 16:15 until 17:02?

     

    Regards,

    Raymond

     


    Yes, you can make this work for other times too. Keep in mind the DateDiff function returns only whole numbers, so it would make more sense to base a time such as 17:02 on Minutes instead of Hours in the calculation. 17:02 = 17x60+2 = 1022 minutes after midnight for the condition.

  • Verified answer
    rho1967 Profile Picture
    141 on at

    Many Thanx,

     

    It works when I refresh the page. But if it has to start itself then it won't be visible. What could this be?

    Do I have to place the video on another page and then navigate to another page at a time?

     

    Thank you very much

     

    Raymond

     

  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    @rho1967 wrote:

    Many Thanx,

     

    It works when I refresh the page. But if it has to start itself then it won't be visible. What could this be?

    Do I have to place the video on another page and then navigate to another page at a time?

     

    Thank you very much

     

    Raymond

     


    The behavior you're seeing is because Today() and Now() do not continuously re-evaluate on their own - they need deliberate action through a behavior formula (one that starts with "On") to return a new value.

     

    One way to deal with this is to create and set a variable using a timer:

    1. Put varVisible in the Visible property you want to control
    2. Insert a timer on the screen, set it to auto-start, repeat, and make it non-visible
    3. Set the timer's duration to 60000 (one minute) and set its OnTimerEnd code to:
    Set(varVisible,
     If(
     DateDiff(Today(),Now(),Hours) >= 11 && DateDiff(Today(),Now(),Hours) < 14, 
     true, 
     false
     )
    )

    Once per minute the app will re-evaluate the expression and toggle the variable & visibility of your control.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 342 Most Valuable Professional

#2
11manish Profile Picture

11manish 234

#3
Valantis Profile Picture

Valantis 187

Last 30 days Overall leaderboard