Skip to main content

Notifications

Community site session details

Community site session details

Session Id : p8rbb2UfXCK363vM4Y3s6h
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,916 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,916 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 Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 123

#2
David_MA Profile Picture

David_MA 104 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 90 Super User 2025 Season 1

Overall leaderboard
Loading started