Hi,
I have two dropdowns, where the user can select the hours and then minutes.
I want to set default values to show current time. While I can do this with Hour(Now()), I can't figure out how to do it for minutes. The dropdown's Items = ["00"; "05"; "10"; "15"; "20"; "25"; "30"; "35"; "40"; "45"; "50"; "55"]
So - how would I do Minute(Now()) and round it down to nearest 5 minutes?
So if the time is 13:24, it would round down to 13:20.
Thanks!
Solved! Go to Solution.
Hi @jernejp
Maybe something like this could work for you:
If( Right(Text(Minute(Now())),1) = "5" || Right(Text(Minute(Now())),1) = "0", Minute(Now()), Value(Right(Text(Minute(Now())),1)) > 0 && Value(Right(Text(Minute(Now())),1)) < 5, Left(Text(Minute(Now())),1) & "0", Value(Right(Text(Minute(Now())),1)) > 5 && Value(Right(Text(Minute(Now())),1)) < 10, Left(Text(Minute(Now())),1) & "5" )
The If statement here does the following:
I think this should do the trick, but maybe someone else here can come up with a more elegant solution.
Hi @jernejp
Maybe something like this could work for you:
If( Right(Text(Minute(Now())),1) = "5" || Right(Text(Minute(Now())),1) = "0", Minute(Now()), Value(Right(Text(Minute(Now())),1)) > 0 && Value(Right(Text(Minute(Now())),1)) < 5, Left(Text(Minute(Now())),1) & "0", Value(Right(Text(Minute(Now())),1)) > 5 && Value(Right(Text(Minute(Now())),1)) < 10, Left(Text(Minute(Now())),1) & "5" )
The If statement here does the following:
I think this should do the trick, but maybe someone else here can come up with a more elegant solution.
Thanks, it works!
I know it is an old tread but had the same question and found this, but I came up with another solution that I wanted to share.
For the items in the dropdown: (instead of [00,01,02,03,....] )
Hour dropdown items: AddColumns(Sequence(24,0),"THours", Text(Value,"00"))
Minutes dropdown items: AddColumns(Sequence(12,0,5),"TMinutes", Text(Value,"00"))
For the minute dropdown default value:
If(
Minute(_time) > 57, "00",
Value(Right(_time,1)) in [3,4,5,6,7], Concatenate(Left(Minute(_time),1),"5"),
Round(Minute(_time),-1)
)
What it does is if minutes is over 57 it will return "00".
Else it will check if the last digit in minutes is in [3,4,5,6,7], if so it returns first digit in minutes concatenated with "5".
Else it will round minute to nearest 10.
_time is a variable that simply is a timer on my start screen that starts and goes through the whole app with pause set to false, duration 1000 ms and on timer start to Set(_Time, Now())
that way _time will always be the same as Now() and if you use the variable instead of Now() the dropdowns will change the default value over time instead of being rendered with Now() once as the screen loads.
For the hour dropdown default value:
If(Hour(_time) = 23 && Minute(_time) > 57, "00", If(Minute(_time) < 57, Text(Hour(_time),"00"), Text(Hour(_time) + 1),"00") )
If you use Hour(Now()) and the time is 15:58 the default values for the dropdowns will be 15:00, with this if statement it will round the hour up if minutes is 58 or higher.
hope this helps.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
User | Count |
---|---|
208 | |
98 | |
59 | |
51 | |
42 |
User | Count |
---|---|
259 | |
160 | |
84 | |
79 | |
57 |