cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

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
Community Support

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
Community Support

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

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

@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
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

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!

Top Solution Authors
Users online (3,658)