Power Automate or Microsoft Flow check day of week

In this Power Automate tutorial, we will discuss the Microsoft flow check day of week. And also discuss the below points:

  • Introduction to power automate dayofweek Function
  • Microsoft flow check day of week
  • Microsoft flow get first day of week
  • Power automate get day from Date
  • Power automate get next monday date
  • power automate check if day is weekend
  • Power Automate get future date
  • Microsoft flow skip weekends
  • Power automate iso week number

Introduction to power automate dayofweek Function

The dayofweek function in Power Automate will return an integer number that represents the day of the week for a date, where Sunday is 0, Monday is 1, and ending on Saturday is 6.

Microsoft flow check day of week

Here we will see how to check the day of week in Microsoft Flow.

Now we will extract the complete day of the week from the given date by using the dayofweek function.

So Create a Manually triggered Flow and then click on the Next step.

microsoft flow check day of week
Microsoft flow check day of week

Now we will initialize the array variable, in which we will assign the array of weekdays name.

Select Initialize variable action, and then set the variable name, type as an array, and set the value with the below array

[
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
]
microsoft flow get day of week
Microsoft flow get day of week

Now, we have to get the current date and time by using the UTC now() function. So for this click on the Next step and select Compose action. Then in input write the below expression

utcNow()
power automate check day of week
power automate check day of week

To get the day of the Week i.e. in Number from the current date. So, click on the Next step, and then select the Compose action. Now in input write the below expression:

dayOfWeek(outputs('Get_current_Date_and_time'))
microsoft flow check day of week
Microsoft flow check day of week

In the above step, we will get the days of the week in number, so now we will convert the number into the day’s full name.

So, click on the Next step and then select the Compose action. In input write the below expression.

variables('DaysOfWeek')[sub(outputs('Get_the_Day_of_the_Week_'),1)]
microsoft flow check day of week
Microsoft flow check day of week

Now click on Save and run the Flow manually to see the result.

microsoft flow check day of week
Microsoft flow check day of week

This is how to check day of the week in Microsoft flow or Power Automate.

Read Power Automate update SharePoint list item

Microsoft flow get first day of week

Here we will see how to get the first day of the week in Power Automate.

For some people the first day of the week is Sunday and for some other people is Monday

So, in Power Automate, select the Manually triggered flow and then click on the Next step.

Microsoft flow get first day of week
Microsoft flow get first day of week

Now we will get the first day of the week, so for this select the compose action. Then in input write the below expression.

For Monday

formatDateTime(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 'yyyy-MM-dd')

For Sunday

formatDateTime(subtractFromTime(utcNow(), dayOfWeek(utcNow()), 'Day'), 'yyyy-MM-dd')

We will use the expression for Monday in Compose action.

Microsoft flow get first day of week
Microsoft flow get first day of week

Now we will convert the above date to the Full name of the day. So for this click on Next step and then select compose action. In input write the below expression:

formatDateTime(outputs('Compose'),'dddd')
Microsoft flow get first day of week
Microsoft flow get first day of week

Now click on Save and run the Flow manually, it will return the first date i.e Monday of the current week.

Microsoft flow get first day of week
Microsoft flow get first day of week

This is how Microsoft flow get the first day of the week.

See also  How to Create a Power BI Dashboard?

Read Trigger Conditions in Power Automate

Power automate get day from Date

Here we will see how to get day from date in Power Automate

Now we will get the day name from the current date in Microsoft Flow.

In Power Automate, select the Manually triggered Flow, then click on Next step.

power automate gat day from date
power automate gat day from date

Select the Compose action and then in input write the below expression.

formatDateTime(utcNow(),'dddd')
power automate gat day from date
power automate gat day from date

Now click on Save and run the Flow manually, we will get the day name from the date.

power automate gat day from date
power automate get day from date

This is how power automate get day from date.

Check out, Power automate approval reminder

Power Automate get next monday date

Here we will see how to get next Monday’s date in Power Automate.

Now we will find the coming Monday date in the Microsoft Flow. For example, today’s date is 08-12-2021 and today is Wednesday, so the next Monday is 13-12-2021.

In Power Automate, select the Manually triggered Flow, and then click on Next step.

power automate get next monday date
power automate get next monday date

Select the compose action, in input write the below expression to get the next Monday.

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)))))))
power automate get next monday date
power automate get next monday date

Now to format the date from the above compose action, click on the Next step and select the compose action. In input write the below expression

formatDateTime(outputs('Compose'),'yyyy-MM-dd')
power automate get next monday date
power automate get next monday date

Now click on Save and run the flow manually, we can see the output i.e. next Monday date.

power automate get next monday date
power automate get next monday date

This is how we can get next Monday date in Power Automate.

Read Power Automate send an email with an attachment from SharePoint

Power Automate check if day is weekend

Here we will see how to check if the day is the Weekend or not in Power Automate.

We will take two examples to check if the day is the weekend or not i.e Sunday or Saturday

  1. We will assign a date to the variable, then we will check if day is weekend or not.
  2. In next example we will check the current date is weekend or not.

Example 1: By assigning a date

In Power Automate, select the Manually triggered Flow. Then click on the Next step.

power automate check if day is weekend
power automate check if day is weekend

Now we will initialize a date to the string variable. Select initialize variable action, then provide the variable name, type as a string, and in value provide the date.

power automate check if day is weekend
power automate check if day is weekend

Now we will add an expression, to check if the date is weekend or not i.e. Saturday and Sunday. So, click on the next step and select the Compose action. In input write the below expression.

if(or(equals(dayOfWeek(variables('Date')),0),equals(dayOfWeek(variables('Date')),6)),formatDateTime(variables('Date'),'dddd'),weekdays)
power automate check if day is weekend
power automate check if day is weekend

Now click on Save and run the flow manually, to see the result in the compose output. So the date is 2021-12-04 which is Saturday, it is a weekend so, it will return Saturday.

power automate check if day is weekend
power automate check if day is weekend

And if it is not the weekend it will return ‘weekdays’ like the below screenshot.

power automate check if day is weekend
power automate check if day is weekend

Example 2: By using the current date

See also  Power Automate increment number in SharePoint list

In Power Automate, select the Manually triggered Flow then click on the Next step.

power automate check if day is weekend
power automate check if day is weekend

Now we will check the current date is the weekend, it will return the days of the name i.e. Sunday or Saturday else it will return the current day.

So, select the Compose action, and in input write the below expression

if(or(equals(dayOfWeek(utcNow()),0),equals(dayOfWeek(utcNow()),6)),formatDateTime(utcNow(),'dddd'),formatDateTime(utcNow(),'dddd'))
power automate check if day is weekend
power automate check if day is weekend

Now click on Save and run the flow manually, As today is Thursday so it will return Thursday.

power automate check if day is weekend
power automate check if day is weekend

This is how power automate check if the day is weekend.

Read Power Automate Switch case

Power Automate get future date

Here we will see how to get future dates in Microsoft Flow or Power Automate.

We will create a flow, in which we will calculate to get the next Monday’s date is at the time of running.

For example run today’s date is 09-12-2021, i.e. Thursday it would return 13-12-2021, if the date is 10-12-2021 then it would return 13-12-2021 and if the date is 13-12-20 then it would return 20-12-2021.

In Power Automate, select the Manually triggered Flow, then click on Next step.

Power Automate get future date
Power Automate get a future date

Now we will calculate to get the future Monday’s date. Select the compose action, then in input write the below expression.

addDays(utcNow(),if(equals(dayOfWeek(utcNow()),0),1,sub(8,dayOfWeek(utcNow()))),'yyyy-MM-dd')
Power Automate get future date
Power Automate get a future date

Now click on Save and run the Flow manually, to see the coming Monday date i.e. 13-12-2021.

Power Automate get future date
Power Automate get a future date

This is how we can get the future date in Power Automate.

Read Power Automate create an HTML table

Microsoft flow skip weekends

Here we will see how to skip or exclude weekends in Microsoft Flow.

In some scenarios we don’t need our flow run on weekends i.e Saturday and Sunday, so for this, we need to skip or exclude the weekend, and it will run from Monday to Friday.

In Power Automate, select the Manually triggered Flow. Then click on the Next step.

Microsoft flow skip weekends
Microsoft flow skip weekends

Now we will initialize a date to a string variable. Select the Initialize variable action, then provide the variable name, type as string, and set the value like below.

Microsoft flow skip weekends
Microsoft flow skip weekends

Now we will write an expression which will skip the weekend.

So, click on the Next step and then select Compose action. Then in Input write the below expression. This expression is if you initialize the date in the variable.

if(equals(dayOfWeek(variables('Date')),0),addDays(variables('Date'),1),if(equals(dayOfWeek(variables('Date')),6),addDays(variables('Date'),2),null))

And if you want to add the current date in the expression accordingly it will skip the weekends, so for this, you can assign the utcNow() to the above variable and write the above expression else write the below expression:

if(equals(dayOfWeek(utcNow()),0),addDays(utcNow(),1),if(equals(dayOfWeek(utcNow()),6),addDays(utcNow(),2),formatDateTime(utcNow(),'dd-MM-yyyy')))
Microsoft flow skip weekends
Microsoft flow skip weekends

Now we will format the date coming from the above step, so click on the Next step and select Compose action. In input write the below expression.

formatDateTime(outputs('Compose'),'yyyy-MM-dd')
Microsoft flow skip weekends
Microsoft flow skip weekends

Now click on Save and run the Flow Manually. As we have provided the date is 2021-12-12, i.e. Sunday, so as a result, we will get 2021-12-13 i.e. Monday.

Microsoft flow skip weekends
Microsoft flow skip weekends

This is how we can skip weekends in Microsoft flow.

See also  How to loop through SharePoint list items in Power Automate

Read Power Automate Forms to Excel

Power automate iso week number

Here we will see how to get the iso week number from the current date or for a year in Power Automate or Microsoft flow.

As there is no function to get the ISO week number in Power Automate. In Excel, we can get the ISOWEEKNUM function.

To get the ISO week number in Power Automate, we must know a couple of things, that is listed below.

  • An ISO 8601 week numbering of year contains either 53 or 52 weeks.
  • ISO 8601 weeks alaways starts on Monday.
  • According to the Gregorian calendar First ISO 8601 week of a year is the first week, that contains the first Thursday.

So Today’s Date is 2021-12-09, so the iso week number is 49 (2021-12-6 to 2021-12-12).

In Power Automate, select the Manually triggered Flow. Then click on the Next step.

power automate iso week number
power automate iso week number

As ISO 8601 week starts on Monday, so we will work on Monday, but in Power Automate number of days of the week begin from 0 is Sunday and 1 is Monday.

So, to calculate Monday, we will subtract the dayofweek value of the current date minus 1, to get a total amount of days to subtract. As of Sunday is 0, so we will add in the If function to set the value to subtract to 6 if the day is Sunday.

Select the Compose action, then in the input field write the below expression

subtractFromTime(utcNow(), if(equals(dayofweek(utcNow()),0),6,sub(dayofweek(utcNow()),1)), 'Day')
power automate iso week number
power automate iso week number

Now we have the Monday value, so we want to find out the value for the Thursday of the current week. We will do as the first ISO 8601 week of the year always have a Thursday in it, so it is best placed to calculate from this day. As we know in After three days of Monday, Thursday come.

So click on the Next step and select Compose action. In input write the below expression.

addDays(outputs('Compose'),3)
power automate iso week number
power automate iso week number

Now we will calculate the ISO week number, so click on the Next step and then select the Compose action, In input write the below expression:

div(add(dayofyear(outputs('Compose_2')),6),7)
power automate iso week number
power automate iso week number

Now click on Save and run the Flow manually, we can see the iso week number in the compose output.

power automate iso week number
power automate iso week number

This is how we can get the iso week number in Power Automate.

Related Power Automate tutorials:

In this Power Automate tutorial, we learned how to check day of week in Microsoft flow or Power Automate. And also we learned the below points:

  • Microsoft flow check day of week
  • Microsoft flow get first day of week
  • Power automate get day from Date
  • Power automate get next monday date
  • power automate check if day is weekend
  • Power Automate get future date
  • Microsoft flow skip weekends
  • Power automate iso week number
>