cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Issues with time calculation (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
Community Support
Community Support

Hi @scottgm ,

 

Thanks for feedback.

 

The issue could be reproduced by me. I will help report it.

 

Further, I found that you could get the previous month without returning to the start of the month, please try with the following code:

startofmonth(getPastTime(1,'month'))

 

startofmonth(subtractFromTime(utcNow(),1,'month'))

 

Please take a try with above function.

 

Best regards,

Mabel

 

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

View solution in original post

3 REPLIES 3
Community Support
Community Support

Hi @scottgm ,

 

Thanks for feedback.

 

The issue could be reproduced by me. I will help report it.

 

Further, I found that you could get the previous month without returning to the start of the month, please try with the following code:

startofmonth(getPastTime(1,'month'))

 

startofmonth(subtractFromTime(utcNow(),1,'month'))

 

Please take a try with above function.

 

Best regards,

Mabel

 

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

View solution in original post

Thank you @v-yamao-msft i'm glad it wasn't just me. 

 

I'll go with the workaround for now.

 

Cheers,

Scott

Hi @scottgm ,

 

Thanks for understanding.

The issue has been reported. And a fix is being rolled out.

 

Best regards,

Mabel

 

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

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (43,616)