Hi all
I have a date picker called DatePickerTo in a Power App that is used to filter the items in a gallery. Users interact with this Power App 24/7.
The DefaultDate property for the date picker is set to Today().
I also have a Reset filters button with OnSelect = Reset(DatePickerTo).
After midnight (i.e. when the date increments by 1), if users click the Reset filters button, the date does not change to the correct value (i.e. the new current day). The only way to set it correctly is by manually changing it or refreshing the app.
Is there a way I can reset the value of Today() so that it updates to the correct date after midnight?
Thanks
Solved! Go to Solution.
@pa111
From Docs
For example, a label control with Label1.Text = Now() will not change while your app is active. Only closing and reopening the app will result in a new value.
The function will be reevaluated if it is part of a formula in which something else has changed. For example, if we change our example to involve a slider control with Label1.Text = DateAdd( Now(), Slider1.Value, Minutes ) then the current time is retrieved each time the Slider control's value changes and the label's text property is reevaluated.
What I suggest is just changing the way you give it the filter, maybe you could store it as a variable then when a user presses the reset button you could reset the variable? or just some other way that has it in a formula
@pa111
From Docs
For example, a label control with Label1.Text = Now() will not change while your app is active. Only closing and reopening the app will result in a new value.
The function will be reevaluated if it is part of a formula in which something else has changed. For example, if we change our example to involve a slider control with Label1.Text = DateAdd( Now(), Slider1.Value, Minutes ) then the current time is retrieved each time the Slider control's value changes and the label's text property is reevaluated.
What I suggest is just changing the way you give it the filter, maybe you could store it as a variable then when a user presses the reset button you could reset the variable? or just some other way that has it in a formula
Thank you @BlessedCobba. I have implemented the fix as follows:
1. Add to the OnVisible property: Set(currentDate,Today())
2. Change the DefaultDate of the date picker to currentDate
3. Add to the OnSelect property of the reset button: Set(currentDate,Today())
I did some testing using the Second(Now()) command, set the default property for an input text control to a temporary variable, and verified that the number does change when you attempt to reset the input text control. It is difficult to verify that the date updates correctly without checking before and after midnight, but I think that this will work.
Thanks again!
User | Count |
---|---|
260 | |
109 | |
92 | |
56 | |
41 |