web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Take current time and ...
Power Automate
Unanswered

Take current time and round up to nearest quarter hour

(1) ShareShare
ReportReport
Posted on by

I need help with a flow app. I want to be able to take the current time, round that time up to the nearest quarter hour and then add 7 minutes to that time.  Then I want to delay the rest of my flow until that time comes. For example: Current time is 15:18, I want it to round up to 15:30 and then add 7 minutes to make it 15:37.  I then want to delay the rest of my flow until that time. 

 

 

Categories:
I have the same question (0)
  • Verified answer
    v-yamao-msft Profile Picture
    on at

    Hi @Anonymous,

     

    I am afraid that there is no round function can be used in flow currently, you may consider submitting a request on Flow Ideas forum for this function:

    https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

     

    Besides, you may try to use the function if to return the value you want according to the existing time. Please take this doc for more details about the function:

    https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference

     

     

    Best regards,

    Mabel Mao

  • GabrielStJohn Profile Picture
    on at

    Hello, @Anonymous!

     

    If you have already posted your idea to the Flow Community Ideas Forum then you need to post the URL to your idea’s thread as a reply to this thread and then "Accept as Solution" on that reply so other users may vote for your Flow Idea and identify the information easily.

     

    Thank You!

     

    -Gabriel
    Flow Community Manager

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    Thank you! I ended using a combo of if statements to accomplish this.

     

    if(lessOrEquals(variables('Minutes'),15),add(sub(15,variables('Minutes')),7),if(and(greater(variables('Minutes'),15),lessOrEquals(variables('Minutes'),30)),add(sub(30,variables('Minutes')),7),if(and(greater(variables('Minutes'),30),lessOrEquals(variables('Minutes'),45)),add(sub(45,variables('Minutes')),7),if(greater(variables('Minutes'),45),add(sub(60,variables('Minutes')),7),0))))
  • WilvertB Profile Picture
    4 on at
    As I came across this post when searching for this issue, since there still seems to be no out-of-the-box solution, I will post my solution for other people who might need it.
     
    This works in separate compose actions or you can make a single long one, combining the formulas. Should also work with AM/PM times if in the last step the formatDateTime is changed accordingly.
     
    Probably someone else will have a more compact/optimised version but here you go.
     
    "TIMEINPUT": Time input
     
    The seconds:
    "OUTPUTSECONDS"div(add(int(formatDateTime(TIMEINPUT'ss')), 30), 60) = either 0 or 1
     
    The minutes:
    "OUTPUTMINUTES"mul(div(add(add(int(formatDateTime(TIMEINPUT'mm')), 7), OUTPUTSECONDS), 15), 15) = either 0, 15, 30, 45 or 60
     
    The hours:
    "OUTPUTHOURS"formatDateTime(addHours(TIMEINPUT, if(equals(OUTPUTMINUTES, 60), 1, 0)), 'HH')
     
    The full time:
    formatDateTime(concat(OUTPUTHOURS':', if(equals(OUTPUTMINUTES, 60), 0, OUTPUTMINUTES), ':00'), 'HH:mm:ss')
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    My try:

    Cut off the seconds and reduce the minutes to the previous full quarter, then add 15 minutes (no issues with next hour/day/month etc).

    Chriddle_0-1720109474048.png

    Chriddle_1-1720109654846.png

     

     

     

     

    addMinutes(
    	concat(
    		slice(outputs('Compose'), 0, 14),
    		mul(
    			div(
    				int(slice(outputs('Compose'), 14, 16)),
    				15
    			),
    			15
    		)
    	),
    	15
    )

     

     

     

     

     

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    Same approach using formatDateTime

     

    addMinutes(
    	formatDateTime(
    		outputs('Compose'),
    		concat(
    			'yyyy-MM-ddTHH:',
    			mul(
    				div(
    					int(formatDateTime(outputs('Compose'), 'mm')),
    					15
    				),
    				15
    			)
    		)
    	),
    	15
    )

     

    As @ChrisSM correctly noted, the above expression fails with 1 digit as the minute.
    Therfore an update:

    addMinutes(
        formatDateTime(
            outputs('Compose'),
            concat(
                'yyyy-MM-ddTHH:',
                formatNumber(
                    mul(
                        div(
                            int(formatDateTime(outputs('Compose'), 'mm')),
                            15
                        ),
                        15
                    ),
                    '00',
                    'es-es'
                )
            )
        ),
        15
    )
  • ChrisSM Profile Picture
    52 on at
    @Chriddle It seems the formatDateTime solution breaks for times that start with 0, like 2024-07-08T17:02:00Z, because int() removes leading zeros. It's not elegant but I added an if statement to check for the length of the output. I changed from 15 to 30 for my own use case.
     
    addMinutes(
        formatDateTime(
            outputs('Compose_12'),
            concat(
                'yyyy-MM-ddTHH:',
                if(equals(length(string(mul(div(int(formatDateTime(outputs('Compose_12'), 'mm')),30),30))), 1), concat(0, mul(div(int(formatDateTime(outputs('Compose_12'), 'mm')),30),30)), mul(div(int(formatDateTime(outputs('Compose_12'), 'mm')),30),30))
            )
        ),
        30
    )
  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at
    Here is your formula to round a number between 0 and 59 to the next 15 minute interval:
    mul(add(int(first(split(string(div(float(outputs('Minutes')),15)),'.'))),1),15)
    Where outputs('Minutes') is the result of a formula like formatDateTime(utcNow(),'MM') or however you get your minutes.

    Here is proof it works:
     
     
    This is much cleaner than a bunch of if statements

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard