cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmistry
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
v-bacao-msft
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
v-bacao-msft
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,750)