Hi, I have a simple flow setup for a SharePoint Task list which triggers when a task is marked as complete and creates a recurring task with due date of next year, I am using following formula for the due date:
Solved! Go to Solution.
@Anonymous
Below I am using a compose to capture only the year and then advancing that value by 1, i also then grab the date and month in another compose and ultimately concatnate them to form the final date. This may work as a workaround until Microsoft fixes the issue with the formula above.
I have tested the following and it seems to work well.
Expressions for the steps above.
Compose: Get Year
formatDateTime(body('Get_item')?['Date'],'yyyy')
Compose: Convert Year to Integer
int(outputs('Compose:_Get_Year'))
Compose: Advance Year
add(outputs('Compose:_Convert_Year_to_Integer'),1)
Compose: Get MM-dd
formatDateTime(body('Get_item')?['Date'],'MM-dd')
Compose: Concat Date
concat(outputs('Compose:_Get_MM-dd'),'-',outputs('Compose:_Advance_Year'))
That will advance the year and will keep the corret day/month.
Also to remove time from dates you can use the formatDateTime expression like below
formatDateTime(body('Get_item')?['Date'],'MM-dd-yyyy')
Hope this helps!
Thanks,
Zach
Hi @Anonymous ,
Thanks for feedback.
I have made some tests on my side and I found that when the due date is the first day of the month, the one off case you’ve mentioned will occur. And it works well on any other date.
I will help report this issue and back to you once I got any updates.
In addition, I have figured out a solution for this issue by using if function to check if it is the first day of a month:
if(equals(dayOfMonth(triggerBody()?['DueDate']),1), addToTime(addDays(startOfMonth(addToTime(triggerBody()['DueDate'],12,'Month')),sub(dayOfMonth(triggerBody()['DueDate']),1),'yyyy-MM-dd'),1,'month'), addDays(startOfMonth(addToTime(triggerBody()['DueDate'],12,'Month')),sub(dayOfMonth(triggerBody()['DueDate']),1),'yyyy-MM-dd'))
Please take a try with it on your side.
Best regards,
Mabel
Thanks @v-yamao-msft for the solution.
Unfortunately when input date is 5/1/2019, it does not work, see screenshot below. Looks like its still an issue with the first of the month, March 1st, 2019 returns march 3, 2020, also the timezone, hh:mm:Ss gets addded, please help.
@Anonymous
Below I am using a compose to capture only the year and then advancing that value by 1, i also then grab the date and month in another compose and ultimately concatnate them to form the final date. This may work as a workaround until Microsoft fixes the issue with the formula above.
I have tested the following and it seems to work well.
Expressions for the steps above.
Compose: Get Year
formatDateTime(body('Get_item')?['Date'],'yyyy')
Compose: Convert Year to Integer
int(outputs('Compose:_Get_Year'))
Compose: Advance Year
add(outputs('Compose:_Convert_Year_to_Integer'),1)
Compose: Get MM-dd
formatDateTime(body('Get_item')?['Date'],'MM-dd')
Compose: Concat Date
concat(outputs('Compose:_Get_MM-dd'),'-',outputs('Compose:_Advance_Year'))
That will advance the year and will keep the corret day/month.
Also to remove time from dates you can use the formatDateTime expression like below
formatDateTime(body('Get_item')?['Date'],'MM-dd-yyyy')
Hope this helps!
Thanks,
Zach
@ZachRoberts you are an absolute genius my friend, this keeps the logic nice and simple. Thank you so much for this, you have no idea how much this has helped me.
Awesome! I am glad that worked for you! Happy to help!
-Zach
Hello, can use something like this for my problem? I would like to build a flow, where reminder is send after the file in folder is older then one year, I use uctnow, but that doesn´t work, I don´t want it to be based on today, but on modified date. Can you please advice, how to set this up? Thank you
Hi @JP21 ,
Yes you can use this flow with some modifications to achieve that. Please see the test flow I created below, I am starting the flow with a recurrence so that the flow will run daily or weekly depending on your need.
I am initializing a variable to store the modified date, this is what we will use to check if the file has not changed in a year.
After grabbing the files from your document library you will want to add an apply to each with the following steps
Expressions for compose steps:
Get Year:
formatDateTime(utcNow(),'yyyy')
Convert Year to Integer:
int(outputs('Get_Year'))
Subtract Year:
sub(outputs('Convert_Year_to_Integer'),1)
Get MM-dd:
formatDateTime(utcNow(),'MM-dd')
Concat Date:
concat(outputs('Get_MM-dd'),'-',outputs('Subtract_Year'))
Set Variable:
set the variable we created above to the expression below
formatDateTime(items('Apply_to_each')?['Modified'],'MM-dd-yyyy')
Use a condition step to compare the Modified date variable to the date string we created if the file is less than or equal to the date.
Then you can setup what to do if it is older or not older
Thanks,
Zach
Hello Zach,
thank you for the instructions, I followed them all, just one additional question, in the last step when I put modified is less or equal to outputs, there are options for all the outputs in the string, should I choose the last one outputs for concat?
Thank you a lot
Hello Zach,
The flow is not working corectly, I don´t know why, the Set variable returns the same date for input and output and the flow triggers the action for if modified date is not less or equal to output it send a reminder, if it is nothing shoul happend, but keep getting the reminders. Also second question I would like for the flow to only consider approved items in the library and ignore pending or rejected items, I try to add a condition, but it´s not working. Should I start with that condition?
User | Count |
---|---|
92 | |
45 | |
21 | |
18 | |
16 |
User | Count |
---|---|
136 | |
49 | |
42 | |
36 | |
28 |