cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## How do I determine the Start and End Dates of the current week?

I am wanting to create two Compose actions that contain the first date in the current week and the last day in the current week based on today's date. I'm sure there is some really clever solution staring me in the face but would appreciate any and all help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User

@Anonymous

The following expression placed in a compose action will give you the beginning of the week:

The following will give you the end of the week:

If you like my response, please give it a Thumbs Up.

Scott
Community Support

Hi @Anonymous ,

What day is the Start and End Dates for the current week on your understanding?

Is that Sunday is the Start Date and Saturday is the End Dates?

If yes, Please refer to screenshot below to create the flow:

the expression for the Start Date of this week is Compose:

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

The expression for the End Date of this week is Compose 2:

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

And you could format the date type with expression below Compose 3-Sart Date:

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

And you could format the date type with expression below Compose 4-End Date:

``formatDateTime(outputs('Compose_2'),'yyyy-MM-dd')``

Best regards,

Alice

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

7 REPLIES 7
MVP
Memorable Member

Hello @Anonymous

Please look at all the expression related to Date and time - then just think you way through the steps using those expressions, a single if equals (if your week starts on a Monday), and one or two sub expressions.

The first date of the current week can then be found 🙂

Kind regards, John

Super User

@Anonymous

The following expression placed in a compose action will give you the beginning of the week:

The following will give you the end of the week:

If you like my response, please give it a Thumbs Up.

Scott
Community Support

Hi @Anonymous ,

What day is the Start and End Dates for the current week on your understanding?

Is that Sunday is the Start Date and Saturday is the End Dates?

If yes, Please refer to screenshot below to create the flow:

the expression for the Start Date of this week is Compose:

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

The expression for the End Date of this week is Compose 2:

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

And you could format the date type with expression below Compose 3-Sart Date:

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

And you could format the date type with expression below Compose 4-End Date:

``formatDateTime(outputs('Compose_2'),'yyyy-MM-dd')``

Best regards,

Alice

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@ScottShearer, that is very helpful. I noticed it is giving Sunday and Saturday as the end dates. Is there a way to configure to give Monday and Friday?

Super User

@Anonymous

Sure - imply add one day for the beginning of week expression and subtract one day for the end of week expression.

Beginning of week - never on Sunday:

If you like my response, please give it a Thumbs Up.

Scott
Anonymous
Not applicable

@ScottShearer, that's awesome. Thank you!

Announcements

#### Back to Basics Tuesday Tip #9: All About the Galleries

This is the ninth post in our series dedicated to helping the amazing members of our community--both new members and seasoned veterans--learn and grow in how to best engage in the community! Each Tuesday, we feature new content that will help you best understand the community--from ranking and badges to profile avatars, from Super Users to blogging in the community. Our hope is that this information will help each of our community members grow in their experience with Power Platform, with the community, and with each other!     Today's Tip: All About the Galleries Have you checked out the library of content in our galleries? Whether you're looking for the latest info on an upcoming event, a helpful webinar, or tips and tricks from some of our most experienced community members, our galleries are full of the latest and greatest video content for the Power Platform communities.   There are several different galleries in each community, but we recommend checking these out first:   Community Connections & How-To Videos Hosted by members of the Power Platform Community Engagement  Team and featuring community members from around the world, these helpful videos are a great way to "kick the tires" of Power Platform and find out more about your fellow community members! Check them out in Power Apps, Power Automate, Power Pages, and Copilot Studio!         Webinars & Video Gallery Each community has its own unique webinars and videos highlighting some of the great work being done across the Power Platform. Watch tutorials and demos by Microsoft staff, partners, and community gurus! Check them out: Power Apps Webinars & Video Gallery Power Automate Webinars & Video Gallery Power Pages Webinars & Video Gallery Copilot Studio Webinars & Video Gallery   Events Whether it's the excitement of the Microsoft Power Platform Conference, a local event near you, or one of the many other in-person and virtual connection opportunities around the world, this is the place to find out more about all the Power Platform-centered events. Power Apps Events Power Automate Events Power Pages Events Copilot Studio Events   Unique Galleries to Each Community Because each area of Power Platform has its own unique features and benefits, there are areas of the galleries dedicated specifically to videos about that product. Whether it's Power Apps samples from the community or the Power Automate Cookbook highlighting unique flows, the Bot Sharing Gallery in Copilot Studio or Front-End Code Samples in Power Pages, there's a gallery for you!   Check out each community's gallery today! Power Apps Gallery Power Automate Gallery Power Pages Gallery Copilot Studio Gallery