cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PGTips
Level: Powered On

RoundDown UTC time

How would I round down the current time in UTC format to the nearest hour or 30 minute interval?

E.g:

Time now = 02/14/2020, 14:28

So I want to set a variable to = 02/14/2020, 14:00 (rounding down to the nearest hour or 30 minute interval)

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: RoundDown UTC time

@PGTips 

Please try this code:

 

Set(myDateVariable,
    Today()
    + Time(Hour(Now(),RoundDown(Minute(Now())/30,0),0)
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
Super User
Super User

Re: RoundDown UTC time

@PGTips 

Please try this code:

 

Set(myDateVariable,
    Today()
    + Time(Hour(Now(),RoundDown(Minute(Now())/30,0),0)
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

GarethPrisk
Level: Powered On

Re: RoundDown UTC time

 

DateAdd(
    Now(),
    (Minute(Now()) * - 1) + If(
        Minute(Now()) >= 30,
        30,
        0
    ),
    Minutes
)

 

The previous response works as well. Thanks @mdevaney

 

EDIT: Corrected mine to account for the 30 minute interval requirement.

PGTips
Level: Powered On

Re: RoundDown UTC time

Amazing, thanks! And then finally, how would I convert to this format: "2020-02-14T09:00:00"

Super User
Super User

Re: RoundDown UTC time

@PGTips
Like this. Try it out in the Text property of a label.

Text(myDateVariable,”yyyy-mm-dd”)&”T”&Text(myDateVariable,”hh:mm:ss”)

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,648)