web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Time compare methods? ...
Power Apps
Answered

Time compare methods? Automating changes based on times.

(0) ShareShare
ReportReport
Posted on by 718

I want to control a Patch to make sure it only happens at a range of local times. I want something to only happen between 3:00 PM and 3:25 PM. One really hacky method I came up with is this:

If(DateDiff(Today(), Now(), Minutes) > 900 And DateDiff(Today(), Now(), Minutes) < 825,
Patch (...)
)

This would trigger when someone presses a button. However it would be great to have it auto trigger visible or not. I am worried this won't work since this won't be evaluated expcet on app start. Any suggestions?

Categories:
I have the same question (0)
  • RezaDorrani Profile Picture
    12,143 on at

    Hi @BrianHFASPS 

     

    You could add a timer control to the app which would run on a schedule and then run your code logic

     

    However this would only work when the App is running

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • BrianHFASPS Profile Picture
    718 on at

    I only need it to happen when app is running so that isn't an issue. I didn't think timers could work on external time but rather would only work on internal to app time. Can you have a timer trigger based on clock time?

  • RezaDorrani Profile Picture
    12,143 on at

    Hi @BrianHFASPS 

     

    Your timer can start and end lets say every 5-10 secs

    Every time timer ends

    you can

    If(DateDiff(Today(), Now(), Minutes) > 900 And DateDiff(Today(), Now(), Minutes) < 825,
    Patch (...)
    )

    and then restarts the timer

     

  • Verified answer
    v-yutliu-msft Profile Picture
    on at

    Hi @BrianHFASPS ,

    I suggest you try the App's OnStart property or Screen's OnVisible property.

    The first one, it will trigger automatically when you run the app.

    The second one, it will trigger automatically when you load this screen.

    Set the App's OnStart property or Screen's OnVisible property to the formula that you listed.

    Or you could try this formula:

    If(TimeValue(Text(Now(),DateTimeFormat.LongTime))>=Time(15,0,0)&&
    TimeValue(Text(Now(),DateTimeFormat.LongTime))<=Time(15,25,0),
    Patch(...),
    .....
    )

     

     

     

  • BrianHFASPS Profile Picture
    718 on at

    Since I am doing an action during OnSelect or AppStart your formula works well. Thanks.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard