cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmistry
Level 8

Flow returns wrong date value

Hi,


I have a flow that runs successfully but does not produce result as expected. I am using a SharePOint task list which has DueDate column, the flow triggers when a task is marked as completed and then creates a task as recurring with a new due date, the flow is created to provision recurring tasks.

 

Capture.JPG

I have a frequency column with values: Annually, Semi Annually, Monthly and Quarterly so based on the value of frequency column, it should change the due date value, for example monthly should add one month to orginal due date, semi annually adds 6, quarterly adds, 3 and annually adds 12 and.

 

Formulas for compose: 

if(equals(triggerBody()?['Frequency']?['Value'],'Annually'),int(12),if(equals(triggerBody()?['Frequency']?['Value'],'Quarterly'),int(3),if(equals(triggerBody()?['Frequency']?['Value'],'Monthly'),int(1),if(equals(triggerBody()?['Frequency']?['Value'],'Semi-Annually'),int(6),null))))
 
Due Date formula in create item:
addToTime(triggerBody()?['DueDate'],outputs('Compose'),'Month')
 
Below screenshot is of task list after flow run.
Capture.JPG
This is the issue, since frequency for task b is quarterly , it adds 3 months to the new due date which is perfect but changes the days value and i do not want that, due date should be 7/20/2019 instead of 7/19/2019, can someone help fix this.
 
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Flow returns wrong date value

Hi @dmistry ,

 

I did a test on my side and it is not possible to determine whether the Month representative is 30 days or 31 days.

It seems that if you use Month to accumulate dates, you can't get the expected date.

If you want the "dd" of the date after the accumulation is the same as before, you could consider using the following Expression:

addDays(startOfMonth(addToTime(triggerBody()['date'],3,'Month')),sub(dayOfMonth(triggerBody()['date']),1),'yyyy-MM-dd')

47.PNG48.PNG

Please take a try.

 

Best Regards,

Community Support Team _ Barry
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 Team
Community Support Team

Re: Flow returns wrong date value

Hi @dmistry ,

 

I did a test on my side and it is not possible to determine whether the Month representative is 30 days or 31 days.

It seems that if you use Month to accumulate dates, you can't get the expected date.

If you want the "dd" of the date after the accumulation is the same as before, you could consider using the following Expression:

addDays(startOfMonth(addToTime(triggerBody()['date'],3,'Month')),sub(dayOfMonth(triggerBody()['date']),1),'yyyy-MM-dd')

47.PNG48.PNG

Please take a try.

 

Best Regards,

Community Support Team _ Barry
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

dmistry
Level 8

Re: Flow returns wrong date value

@v-bacao-msft  thanks a bunch, exactly what I was looking for.

dmistry
Level 8

Re: Flow returns wrong date value

@v-bacao-msft   is it possible to keep the month number also same like you showed for Day. I have a change in requirement, now only year value needs to be changed. So for startofmonth, I am passing in 12 instead of 3 as you showed which adds a year to the current date and day value remains same.

 

However, in an off case, for date: 5/1/2019 (first of every month), flow gives me 4/1/2020, in theory, i want this to be 5/1/2020. So the month and day now should not changed but only year value, can you please help me with the revised formula?

 

Please help @v-bacao-msft , much appreciated in advance. 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,459)