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

Problem with Subtract from Time (in months)

Hello all, 

 

I am building a workflow where I need to add/remove x-number of days to either the beginning or end of current, previous and next month. I have this part nailed down and working as expected. The date calculations are based on 3 initial values using these calculations:

 

CurrentMonth =  (expecting May)

startOfMonth(utcNow())

PreviousMonth =  Expecting April --> Actual is March

subtractFromTime(outputs('CurrentMonth'),1,'Month')

NextMonth = (expecting June)

startOfMonth(addToTime(utcNow(),1,'Month'))

Date_issue.jpg

 

 

This all worked as expected a few days ago, but now when I test on 1st May. The value for PreviousMonth is returning March 31st. My best guess is that by subtracting 1 Month, it is actually subtracting 31 days? 

 

I could work around this by subtracting 4-weeks rather than 1-month but I'd like to know if I am missing anything here or if someone has seen a similar issue?

 

Thanks,

Scott 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-zhos-msft
Level 10

Re: Problem with Subtract from Time (in months)

Hi @scottgm ,

I have made some tests on my side.

It has the same issue as yours.

As you said, the cause is subtracting 1 Month, it is actually subtracting 31 days.

Capture6.PNGCapture7.PNG

I suggest you  subtract 4-weeks here, or use the getPastTime function for a try.

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

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 REPLY 1
v-zhos-msft
Level 10

Re: Problem with Subtract from Time (in months)

Hi @scottgm ,

I have made some tests on my side.

It has the same issue as yours.

As you said, the cause is subtracting 1 Month, it is actually subtracting 31 days.

Capture6.PNGCapture7.PNG

I suggest you  subtract 4-weeks here, or use the getPastTime function for a try.

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

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 207 members 4,030 guests
Please welcome our newest community members: