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

Extract wekday date

Hi,

 

How to extract a date of the e.g. last Sunday?

1 ACCEPTED SOLUTION

Accepted Solutions
v-zhos-msft
Level 10

Re: Extract wekday date

Hi Dziurgis ,

According to you description, you want to check whether the date fields is in this week based on the current date.

I have made a test on my side, please take a try with the following workaround:

The expression of Compose: sub(0,dayOfWeek(utcNow())), this action is to get the number of the days have passed of this week.

The expression of Compose 2: sub(6,dayOfWeek(utcNow())), this action is to get the number of the days have left of this week.

The first expression of Condition: greaterOrEquals(outputs('Compose_3'),addDays(utcNow(),outputs('Compose')))

The second expression of Condition: lessOrEquals(outputs('Compose_3'),addDays(utcNow(),outputs('Compose_2')))

1.png

Best Regards,

Zhongys

 

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Extract wekday date

Hi @Dziurgis

 

Could you please provide more information on what you are trying to achieve? Do you need to compare a date value with another and check the day of the week? Or are you always checking if a given date is the previous Sunday?

Any screen shots of your flow as it is currently stands would also be helpful in assisting you.


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

Proud to be a Flownaut!


Dziurgis
Level: Powered On

Re: Extract wekday date

Hi LeeHarris,

 

I need to implement a requirement to the flow which executes the following actions:

Precondition: There is a list with items. Flow starts after new item created.

Actions:

- Filter existing items of the particular user (the creator of the new item) with statuses "Approved" or "Done"

- Check date fields in each item and if there is an item with the date in this week (can be from Sunday or Monday. It does not matter) execute the condition:

  - if yes -> change status to new created item and send email

  - if no -> start approval process to new item

 

The issue here, that I do not know how to dynamically check if the date belongs to this working week or not.

Super User
Super User

Re: Extract wekday date

Hi @Dziurgis

 

If you only want to check previous days in the week based on the current date then you can use the below in a condition.

 

dayOfWeek(triggerBody()['date'])  is less than or equal to  
dayOfWeek(utcNow())
 
Replace triggerBody()['date'] with the date from your new item. The dayOfWeek function will return an integer value for each day with Sunday being 0 and Saturday being 6. 

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

Proud to be a Flownaut!


v-zhos-msft
Level 10

Re: Extract wekday date

Hi Dziurgis ,

According to you description, you want to check whether the date fields is in this week based on the current date.

I have made a test on my side, please take a try with the following workaround:

The expression of Compose: sub(0,dayOfWeek(utcNow())), this action is to get the number of the days have passed of this week.

The expression of Compose 2: sub(6,dayOfWeek(utcNow())), this action is to get the number of the days have left of this week.

The first expression of Condition: greaterOrEquals(outputs('Compose_3'),addDays(utcNow(),outputs('Compose')))

The second expression of Condition: lessOrEquals(outputs('Compose_3'),addDays(utcNow(),outputs('Compose_2')))

1.png

Best Regards,

Zhongys

 

View solution in original post

Dziurgis
Level: Powered On

Re: Extract wekday date

Thank you, v-zhos-msft. This is exactly what I needed.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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

Top Kudoed Authors (Last 30 Days)
Users online (4,544)