cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
abbe83
Level: Power Up

addDays expression (Thursday - Sunday)

Hi all,

I would like to do a small customizing of a Flow that I have.

Email with high priority > Create a to-do item in Microsoft To-Do

 

It will create a To-Do item with a reminder 2 days later.

 

Expression that I simply copied from a forum:

addDays(utcnow(), 2, 'yyyy-MM-dd')
 
Now, here is the tricky part (for me, since I am not a coder).
 
1. I want emails that I get from Thursday - Sunday to be set to as the reminder date as Tuesday the following week.
So emails that I get from Monday - Wednesday does not need to be changed, anything in this range should not be affected.
Only emails from Thursday - Sunday.
 
2. I want it to set as a reminder 1 PM, now the time is set in swedish time to 1 AM which is obviously not a good time.
 
3. I want to change the time to swedish time. (UTC +01.00)
 
I believe a lot of people could have use for this kind of reminder so I am really hoping that someone can help me out and I could submit it to Microsoft or if someone else does I dont really care. Lets make it happen.
3 REPLIES 3
Community Support Team
Community Support Team

Re: addDays expression (Thursday - Sunday)

Hi @abbe83,

 

About #1, please consider using workflow definition language function dayofweek to return the day of week component of a string timestamp. Sunday is 0, Monday is 1, and so on.


I assume that your flow should be triggered by “Office 365 Outlook – when new email arrives”, you could use the dynamic content “Received time” from the trigger.


Add a Compose action to return the day of week component of the received time.


The function could be configured likes:

dayofweek(triggerBody()?['DateTimeReceived'])


After the Compose action, you could try to use Switch cases. As we know that Thursday is 4, Friday is 5, and so on. So you can add cases likes below to create a to-do task according to the return value.

 


In the action “Add a to-do”, add days according to the return value so that you can create a reminder date as Tuesday the following week.


Say if the received date is Thursday, the function for the reminder date is:

adddays(triggerBody()?['DateTimeReceived'],5,'yyyy-MM-dd')


The flow could be configured to something likes below:
3.PNG

 


Reference materials:
Workflow definition language
Switch case

About #2 and #3, you may consider using the action “Convert time zone” in your flow.

 

Please check this blog for more details:
https://flow.microsoft.com/en-us/blog/working-with-dates-and-times/


Best regards,
Mabel Mao

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.
abbe83
Level: Power Up

Re: addDays expression (Thursday - Sunday)

Ok all setup now, ignored the time thing for now as that would be complex. Will test and get back.

abbe83
Level: Power Up

Re: addDays expression (Thursday - Sunday)

Once again thanks for the help.

So the emails are getting through to my todo but the reminder date is not being set.

 

So I am wondering what I am doing wrong.

I have created switch cases. See images for understanding, sorry its in Swedish though.

 

1. I have the email, sends when high Priority, nothing else set. This part works.

2. Then see the image below, the Input (Indata) is like you wrote this, exactly this

dayofweek(triggerBody()?['DateTimeReceived'])

 

3. Below it is just the Ouput for the Switch cases.

 

4. I have a feeling that either entry in point 2 is incorrect but more likely is the input in the To-Do below

For example below we have for Sunday which you said is day 0.

The reminder date is formatted exactly like this

adddays(triggerBody()?['DateTimeReceived'],2,'yyyy-MM-dd')

 

Because I want it to set it to Tuesday.

Have I set it incorrectly? How will the system understand that its this coming Tuesday?

 

I have used the same logic 

 

5. Here is how I set all of them

Case 0

 

Expression

adddays(triggerBody()?['DateTimeReceived'],2,'yyyy-MM-dd')

 

---

 

Case 1

 

Expression

adddays(triggerBody()?['DateTimeReceived'],3,'yyyy-MM-dd')

 

---

 

Case 2

 

Expression

adddays(triggerBody()?['DateTimeReceived'],4,'yyyy-MM-dd')

 

---

 

Case 3

 

Expression

adddays(triggerBody()?['DateTimeReceived'],5,'yyyy-MM-dd')

 

---

 

Case 4

 

Expression

adddays(triggerBody()?['DateTimeReceived'],2,'yyyy-MM-dd')

 

---

 

Case 5

 

Expression

adddays(triggerBody()?['DateTimeReceived'],2,'yyyy-MM-dd')

 

---

 

Case 6

 

Expression

adddays(triggerBody()?['DateTimeReceived'],2,'yyyy-MM-dd')

 

Very grateful for help, I am missing something, but what?!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

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

Top Kudoed Authors
Users Online
Currently online: 60 members 4,870 guests
Please welcome our newest community members: