cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Time compare methods? Automating changes based on times.

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Time compare methods? Automating changes based on times.

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(...),
.....
)

 

 

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Dual Super User
Dual Super User

Re: Time compare methods? Automating changes based on times.

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

Highlighted
Post Patron
Post Patron

Re: Time compare methods? Automating changes based on times.

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?

Highlighted
Dual Super User
Dual Super User

Re: Time compare methods? Automating changes based on times.

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

 

Highlighted
Community Support
Community Support

Re: Time compare methods? Automating changes based on times.

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(...),
.....
)

 

 

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Post Patron
Post Patron

Re: Time compare methods? Automating changes based on times.

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

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,173)