cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jernejp
Helper IV
Helper IV

Rounding time to nearest 5 minutes in a dropdown

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!

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

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:

 

  • If the right most character ends in 5 or 0, the minute value remains as it is.
  • If the right most character is between 1 and 5, replace the right most character with 0.
  • If the right most character is between 6 and 9, replace the right most character with 5.


I think this should do the trick, but maybe someone else here can come up with a more elegant solution.

 

View solution in original post

2 REPLIES 2
timl
Super User
Super User

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:

 

  • If the right most character ends in 5 or 0, the minute value remains as it is.
  • If the right most character is between 1 and 5, replace the right most character with 0.
  • If the right most character is between 6 and 9, replace the right most character with 5.


I think this should do the trick, but maybe someone else here can come up with a more elegant solution.

 

View solution in original post

Thanks, it works! 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,401)