cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

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
Highlighted
Super User
Super User

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

@pwrappr01 

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

addDays(utcNow(),mul(dayOfWeek(utcNow()),-1),'yyyy-MM-dd')

 

The following will give you the end of the week:

addDays(utcNow(),add(6,mul(dayOfWeek(utcNow()),-1)),'yyyy-MM-dd')

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Highlighted
Community Support
Community Support

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

Hi @pwrappr01 ,

 

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:

1.png2.png

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.

View solution in original post

7 REPLIES 7
Highlighted

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

Highlighted
Impactful Individual
Impactful Individual

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

Hello @pwrappr01 

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 🙂

What have you tried already?

Kind regards, John

Highlighted
Super User
Super User

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

@pwrappr01 

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

addDays(utcNow(),mul(dayOfWeek(utcNow()),-1),'yyyy-MM-dd')

 

The following will give you the end of the week:

addDays(utcNow(),add(6,mul(dayOfWeek(utcNow()),-1)),'yyyy-MM-dd')

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Highlighted
Community Support
Community Support

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

Hi @pwrappr01 ,

 

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:

1.png2.png

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.

View solution in original post

Highlighted
Helper IV
Helper IV

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

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

Highlighted
Super User
Super User

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

@pwrappr01 

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:

addDays(addDays(utcNow(),mul(dayOfWeek(utcNow()),-1),'yyyy-MM-dd'),1,'yyyy-MM-dd')

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Helper IV
Helper IV

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

@ScottShearer, that's awesome. Thank you!

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!

Users online (7,130)