cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
djw1005
Helper I
Helper I

What is the correct syntax for subtractFromTime(variables('Start'),variables('TotalDays'),Days)

What is the correct syntax for 
 
subtractFromTime(variables('Start'),variables('TotalDays'))
7 REPLIES 7
efialttes
Super User
Super User

Hi
I don't think subtractFromTime is a valid function in Flow. As far as I know the available functions for Flow expressions are defined here
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language
Maybe the ticks() function can help you to substraction two dates
Hope this helps


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Duplicated



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



efialttes
Super User
Super User

Hi again
I've found this thread discussing a similar need (i mean if it is to calculate time difference between two dates). It's from June, so not sure if there is any available improvement since then

https://powerusers.microsoft.com/t5/General-Flow-Discussion/Time-difference/td-p/40756

 

Please note some weeks ago a very useful method to calculate time difference was detailed here, based on ticks() function:

https://flow.microsoft.com/en-us/blog/email-digest-date-manipulations/

 

But if you need to add/substract days instead of time difference between two dates, you have addDays() function (see the link in my first post for more info)

 

Hope this helps

 


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



efialttes
Super User
Super User

Duplicated



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



v-xida-msft
Community Support
Community Support

Hi @djw1005,

 

Do you use subtractFromTime() function within expression in Microsoft Flow?

 

 

The subtractFromTime() function substract an integer number of a specified unit of time from a string timestamp passed.

The first parameter of subtractFromTime() function requires a string timestamp. The second parameter requires the number of a specified time unit to subtract. The third parameter requires the unit of time specified in the interval to subtract. The forth parameter is optional, which is used to specify time format.

 

I have made a test on my side and the flow works well. My flow’s configuration as below:8.JPG

The flow works successfully as below:9.JPG

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Sorry I didn't know in MS Flow you can use functions other than the ones defined in WDL. I will open an independent thread to ask for documentation on these extra funcions.

Thanks for sharing and also for your excellent support!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Collin_Davis
Advocate I
Advocate I

I have used this in a couple of different flows and this is the correct syntax if you want to take a certain number of days away from a desired time:

 

subtractFromTime(utcNow(), 7, 'Day')

 

This would take today's date and subtract 7 days from it. I hope this helps.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (2,179)