cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

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.
4 REPLIES 4
Highlighted
Community Support
Community Support

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.
Highlighted
New Member

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.

Highlighted
New Member

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?!

Highlighted
Frequent Visitor

Re: addDays expression (Thursday - Sunday)

Hi @v-yamao-msft!

 

If I need to calculate a 'Due Date' that is 30 BUSINESS DAYS from today, could I utilize any of this logic?

 

So far, I know that the following formula gives me 30 days from today, but that includes weekends: 

formatDateTime(addDays(utcNow(), 15), 'yyyy-MM-dd').

 

Any ideas on how to calculate 30 business days from today would be greatly appreciated!!!

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (10,284)