How to Use Power Automate dayOfWeek Function?

While undertaking a project, I faced an issue regarding a date-related task that required determining the day of the week for a specific date. I created a Power Automate flow to get the day of the week for a particular date, and I thought I would share this through this post.

In this article, I will tell you what the dayofweek Power Automate is, how to use dayofweek(utcnow()), Power Automate get day of week, and many more like:

  • Power Automate dayofweek function
  • Power Automate check day of week
  • power automate if today is Monday
  • Power Automate get weekday from date

dayofweek Power Automate

Power Automate dayofweek() function determines the day of the week for a particular date. Based on the provided timestamp, this function returns an integer representing the day of the week for the date.

DayValue
Sunday0
Monday1
Tuesday2
Wednesday3
Thursday4
Friday5
Saturday6

The below-provided code will represent the syntax that can be used in the Power Automate flow:

dayOfWeek('timestamp')

dayofweek(utcnow()) Power Automate

To get the day of week number for the current date in Power Automate, see the example below:

Example:

Assuming that today’s date is 29-04-2024, I wanted to get the day of the week for this specific date. The result will give the week number like “1,” which means Monday.

Power Automate get week day utcNow

For that, you can follow the steps below:

1. Browse Power Automate with your Microsoft credentials -> In the Power Automate Home page, tap +Create -> Select Instant cloud flow -> Provide a flow name & select trigger Manullay trigger a flow -> Tap Create button.

2. Take an Initialize variable flow action to initialize the Today’s date. Provide the parameters like Name, Type as String, and Value as utcNow().

dayofweek Power Automate

3. After that, take a Compose flow action; in the Inputs section, enter the expression provided below.

dayOfWeek(variables('Day of year'))

Click OK.

dayofweek(utcnow()) Power Automate

4. After completing the flow, Save the flow. Then, test the flow manually.

5. The compose flow action outputs will represent a numerical day of the week. Each number corresponds to a different weekday.

  • Here, the return value is “1“, which represents Monday.
Power Automate get week number

This is how to get the day of the week for the utcNow() in Power Automate.

Power Automate dayofweek

To get the day of week name for a trigger date, check out the below example:

Example:

In this example, I will trigger a date, ‘01-05-2024‘. My requirement is to get the week’s name for this specific date. The result will be “Wednesday.”

Power Automate get day from date

Go through the below steps to achieve this:

1. Create a Power Automate Instant cloud flow and take Date input inside to the trigger.

2. Then, select Initialize variable action, set the variable name, type as an array, and set the value with the below array with week names.

Power Automate day of week

3. To get the day of the week in number for the trigger date, add the Compose action. Now, in input, write the below expression:

dayOfWeek(triggerBody()?['date'])
Power Automate get day of week

4. Now, we have to convert the number into the day’s full name. For that, add a Compose flow action and provide the expression.

variables('Week days')[sub(outputs('Day_of_week'),1)]
day of week Power Automate

5. When the flow gets ready, save and run the flow. In the Runflow window, select a Trigger date and click on Runflow.

Power Automate day of the week

6. The output will display the Trigger date and day of week name, as you can see in the screenshot below:

Power Automate check day of week

This way, you can get the weekday name for a particular date in Power Automate.

Power Automate If Today is Monday

To get Monday from the dayofweek() function, check the below example:

1. In Power Automate, select the Manually triggered flow.

2. Now, to get the first day of the week, select the compose action. Then, in input, write the below expression.

formatDateTime(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 'yyyy-MM-dd')
Power Automate if today is monday

Save and run the flow manually.

Output:

The output will then return on the first day of the week, which is Monday of the current week.

dayofweek() Power Automate

This way, you can get the first day of the current week using the Power Automate dayofweek() function.

Power Automate check if a day is a weekend

To check if a day is a weekend or not in Power Automate, see the example below.

Example:

Assume a specific date as ‘04-05-2024‘ if the provided date is the weekend, i.e.,[Saturday and Sunday]. It will return the weekend name or else it will return as ‘Weekday.’

How to check weekend for a date in Power Automate

Follow the steps:

1. In Power Automate, select the Manually triggered flow and take Date as an input.

2. Select initialize variable action, then provide the variable name, type as a string, and in value provide the Trigger date from dynamic content.

Power Automate check weekend from date

3. Next, select the Compose action. In input, write the below expression. Here, will add an expression to check if the date is a weekend or not, i.e., Saturday and Sunday.

if(or(equals(dayOfWeek(variables('Date')),0),equals(dayOfWeek(variables('Date')),6)),formatDateTime(variables('Date'),'dddd'),weekdays)
Power Automate check if a date is weekend

4. Now click on Save and run the flow manually. In the Runflow window, trigger a date-> Click on the Runflow button.

Power Automate check if a day is a weekend

5. If the trigger date is a weekend, then it will display the week name like below for that particular date as shown in below figure:

Power Automate get weekend day from date

This is how to check if a day is a weekend or not in Power Automate.

Power Automate Get Weekday from Date

To get the weekday from the SharePoint date column, check the below example:

Example:

For this example, I will use one of my SharePoint lists [Project Details] with a Project start date as a date and time column. Check the image below:

Power Automate check weekday

Whenever an item is created in this list with a Project start date, my task is to retrieve the weekday from the date column, ignoring the weekends [Sunday and Saturday].

Power Automate get day of the week name

To achieve this, see the below example:

1. Create a Power Automate ‘Automated cloud flow‘ with a trigger ‘When an item is created.’ Inside the trigger, provide the Site Address and List Name.

Power Automate get weekday from date

2. Next, take an Initialize variable flow action to initialize the SharePoint date column. Set the parameters like Name, Type as string, and Value from dynamic content.

How to get day from date in Power Automate

3. Add one more Initialize variable and set the variable name, type as an array, and set the value with the array below with week names.

Power Automate dayofweek expression

4. After that, include the Compose action to give the dayofweek() expression, which will give the day of the week from a date.

Get day of week Power Automate

4. Here, I will use a Condition control to eliminate the weekends from the generated output. Add the below conditions:

@outputs('Compose_-_Get_weekday_number') is not equal to 0
                                      (or)
@outputs('Compose_-_Get_weekday_number') is not equal to 6
How to check weekday from date Power Automate

5. Under True conditions, take a Compose action to display the weekday name. Provide the below-given expression in it.

variables('Week days')[sub(outputs('Compose_-_Get_weekday_number'),1)]
How to get day from date using Power Automate

6. Once the flow is completed. Save and run the flow. Now, add an item to the SharePoint list as shown in the figure below:

dayofweek in Power Automate

7. If the created item with ‘Project start date‘ has a weekday, then it will return the weekday name and be displayed in the compose section

Power Automate get day of the week

This way, you can get the weekday from date using Power Automate.

Additionally, you may like:

Conclusion

I trust this Power Automate tutorial is easy and understandable. Here, I have covered the below topics like:

  • Power Automate dayofweek() function
  • How to get a day of the week for the current date in Power Automate
  • Power Automate get week name
  • How to get Monday from Power Automate dayofweek()
  • Get weekday from date in Power Automate
  • Power Automate check if a day is a weekend
>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…