cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Marty3012
Level: Powered On

Take current date and display date of forthcoming Monday

Hi,

 

The function below takes the current date and calculates the date 3 days after;

 

formatDateTime(addDays(utcNow(),3),'yyyy-MM-dd')
 
However, I would like the function to display the date of the next forthcoming Monday without having to state how many days this is offset from. Furthermore, if the current date falls on a Monday, I would like the calculated date to not be the current date, but rather the following Monday. Hope that makse sense!
 
Any help appreciated.
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Take current date and display date of forthcoming Monday

Hi @Marty3012

 

Please refer to screenshot below to get the date of the following Monday:

Capture.PNG

 

The expression in the Compose as below:

if(equals(dayOfWeek(utcNow()),1),addDays(utcNow(),7),if(equals(dayOfWeek(utcNow()),2),addDays(utcNow(),6),if(equals(dayOfWeek(utcNow()),3),addDays(utcNow(),5),if(equals(dayOfWeek(utcNow()),4),addDays(utcNow(),4),if(equals(dayOfWeek(utcNow()),5),addDays(utcNow(),3),if(equals(dayOfWeek(utcNow()),6),addDays(utcNow(),2),if(equals(dayOfWeek(utcNow()),0),addDays(utcNow(),1),null)))))))

The expression in the Compose 2 as below:

formatDateTime(outputs('Compose'),'yyyy-MM-dd')

The flow would run successfully as below:

Capture.PNG

 

Please let me know if your problem could be solved.

 

 

Best regards,

Alice

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Take current date and display date of forthcoming Monday

Hi @Marty3012

I'm having a think at ways you can achieve this but think it would be helpful if you could post pictures of your flow with any detail possible. Could you do that?


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Marty3012
Level: Powered On

Re: Take current date and display date of forthcoming Monday

Current flow is shown below. What I'm trying to do is add the date for the forthcoming Monday in the Body of the Send Email section. The FormatDateTime() function in the body of the email is what I have at the moment.

Thanks

 

Flow - Ex.png

Super User
Super User

Re: Take current date and display date of forthcoming Monday

I am just having a look and trying to create using preset variables and some conditions. Basically test all the day of week logic an advance of populating the email, then populate the email with the following Monday in that way. you may want to look at dayOfWeek() in line with your expression. I'll update later once I get somewhere.


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Highlighted
Community Support Team
Community Support Team

Re: Take current date and display date of forthcoming Monday

Hi @Marty3012

 

Please refer to screenshot below to get the date of the following Monday:

Capture.PNG

 

The expression in the Compose as below:

if(equals(dayOfWeek(utcNow()),1),addDays(utcNow(),7),if(equals(dayOfWeek(utcNow()),2),addDays(utcNow(),6),if(equals(dayOfWeek(utcNow()),3),addDays(utcNow(),5),if(equals(dayOfWeek(utcNow()),4),addDays(utcNow(),4),if(equals(dayOfWeek(utcNow()),5),addDays(utcNow(),3),if(equals(dayOfWeek(utcNow()),6),addDays(utcNow(),2),if(equals(dayOfWeek(utcNow()),0),addDays(utcNow(),1),null)))))))

The expression in the Compose 2 as below:

formatDateTime(outputs('Compose'),'yyyy-MM-dd')

The flow would run successfully as below:

Capture.PNG

 

Please let me know if your problem could be solved.

 

 

Best regards,

Alice

View solution in original post

Marty3012
Level: Powered On

Re: Take current date and display date of forthcoming Monday

That works! Thanks very much for your help.

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

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!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,446)