Skip to main content

Notifications

Community site session details

Community site session details

Session Id : h7d0Oz6YeFhBcrW/TyOpQC
Power Automate - Building Flows
Answered

Rounding up/down from datetime

Like (0) ShareShare
ReportReport
Posted on 31 May 2024 08:09:43 by 141

Hi,

 

I have trouble manipulating datetime, i get this format: (dd-MM-YYYY hh:mm:ss)

 

Start time: 01-02-2024 06:08:13 

End time: 01-02-2024 06:12:42

 

I then want to format it into this (Rounded up or down to the NEAREST 30 minutes)

Start time rounded: 01-02-2024 06:00:00 

End time rounded: 01-02-2024 06:00:00

 

I would also like to just get the time:

Time only: 06:00:00

  • MadsV Profile Picture
    141 on 12 Jun 2024 at 07:54:52
    Re: Rounding up/down from datetime

    Hi @David_MA,

     

    Thanks a lot for the help! 🙂

  • David_MA Profile Picture
    10,607 Super User 2025 Season 1 on 11 Jun 2024 at 13:04:07
    Re: Rounding up/down from datetime

    Yes, you can use one of the @triggerbody values, but it must be a date/time field such as Created or Modified.

  • MadsV Profile Picture
    141 on 11 Jun 2024 at 08:09:08
    Re: Rounding up/down from datetime

    Hi, 

     

    Thanks a lot for the reply! 
    I've been away, so thats why i'm replying so late. I am wondering how I would go about doing it when my datetime comes from Sharepoint when a new element is made. 

     

    I have the "@{triggerBody()?['Title']}" do i just replace utcNow() with the @triggerbody?

  • Verified answer
    David_MA Profile Picture
    10,607 Super User 2025 Season 1 on 31 May 2024 at 19:16:00
    Re: Rounding up/down from datetime

    This may not be the most glamourous or efficient way to do this, but this works:

    David_MA_0-1717182513058.png

    On the No side of the condition:

    David_MA_1-1717182546454.png

    Initialize three variables:

    1. Hour (String)
    2. Minute (Integer)
    3. Rounded Minutes (String) with a default value of 00 (zero zero)

    Set the default value of Hour to:

    formatDateTime(utcNow(),'HH')

    Set the default value of Minute to:

    int(formatDateTime(utcNow(),'mm'))

     

    Then the logic checks:

    1. If the minutes is 0 to 15, it rounds to 00.
    2. If the minutes is 16 to 45 it rounds to 30.
    3. Sine the default is 00, 46 to 59 rounds to 00 automatically.
    4. Then in the compose action combine the data to get just the time.
    5. David_MA_2-1717182900207.png

      You'll need to adjust the hours for your time zone.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard
Loading started
Loading complete