Power Automate dayOfWeek() Function [With Examples]

While working on a project, I came across a particularly challenging date-related task where I had to figure out the day of the week for a certain date. Microsoft has a fantastic Power Automate dayOfWeek() Function to accomplish this.

This article assists you in knowing what the dayOfWeek() function in Power Automate, its syntax, and how to use it with various scenarios like:

  • How to get the day-of-week number in Power Automate (utcNow)
  • Get the day of week name in Power Automate (utcNow)
  • How to get Power Automate the first day of week name (utcNow)
  • Power Automate day of week number from the SharePoint list

Power Automate dayOfWeek() Function

The dayOfWeek() function in Microsoft Power Automate, also known as Microsoft Flow, is used to determine the day of the week for a specified date. This function is part of the expressions used in Power Automate to manipulate and work with data in your workflows.

The dayOfWeek() function is a part of Power Automate’s broader suite of functions for date and time manipulation, which allows for sophisticated and dynamic workflows based on time-based criteria.

This function returns an integer representing the day of the week for the date based on the provided timestamp.

DayValue
Sunday0
Monday1
Tuesday2
Wednesday3
Thursday4
Friday5
Saturday6

The day of that particular date will be displayed, for example, if the date is “12-12-2023“. And Tuesday will see the outcome.

dayOfWeek() expression in Power Automate

This is the overview of the Power Automate dayOfWeek() function.

Power Automate dayOfWeek() Syntax

The Power Automate dayOfWeek() function syntax will look like as shown below:

dayOfWeek('timestamp')

The ‘dayOfWeek()‘ expects a single parameter that is a timestamp in the expression; if not, it will generate an error in the flow.

Parameters:

Timestamp: It works with only the parameter required to be a ‘String’ and mandatory to provide.

The return value is an integer that gives the output as the day of the week from the specified timestamp.

Example:

dayOfWeek('2023-12-11T13:27:36Z')

Where,

  • 2023-12-11T13:27:36Z = Give the date as per your requirement.

This function will return the output as ‘‘3’, the numerical day of the week.

This is about the format of Power Automate dayOfWeek() expression syntax.

Power Automate Day Of Week Number (utcNow)

Let’s begin with how to get the day-of-week number in Power Automate.

Example:

For example, let’s assume today’s date is “12-12-2023“. I need to know the current date’s day [Sunday]. Then, my result will be in the form of an integer ‘2‘. Whereas the ‘2’ value represents the numerical notation of the day.

Power Automate dayOfWeek() number

For that, you can follow the steps that are mentioned 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. Afterward, take an ‘Initialize Variable’ flow action to store values throughout the flow. Ensure to specify details:

  • Name: Enter the variable name manually as the Day of week.
  • Type: Select the type of a variable as String.
  • Value: Select field -> Click Expression -> Add the code.
utcNow()

After giving the expression, Click OK.

Power Automate dayOfWeek utcNow

3. Select and add a Compose flow action to give the dayOfWeek() expression to find out the numerical day of the week of utcNow() as shown below:

Inputs: Select the field -> Click on Expression -> Place the below code.

dayOfWeek(variables('Day of week'))

Click OK.

Power Automate dayOfWeek() Function

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

5. The compose flow action indicates that the dayOfWeek() function will extract the numerical representation of the day of the week. Each number corresponds to a different weekday.

  • Here, the return value will be 2, which represents Tuesday.
Power Automate dayOfWeek() Format

This is how to process the week number of the current day using the Power Automate dayOfWeek function.

Power Automate Day Of Week Name (utcNow)

In this scenario, we will see how to extract the day of the week name in Power Automate.

Example:

Suppose you want to know the current day of the week based on today’s date, which we will assume to be Today’s date as”12-12-2023“. The corresponding day of the week is Tuesday.

Power Automate dayOfWeek Name (utcNow) function

Do follow the below-mentioned steps:

1. Let’s initialize the array variable to assign the array of weekday names. To do so, follow these steps:

  • Choose the “Initialize variable” action.
  • Assign a variable Name and set its Type as an array.
  • Set the variable’s value as the array: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday].
[
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
]
Power Automate dayOfWeek Name (utcNow)

2. Then, take a ‘Compose‘ flow action to add the dayOfWeek() expression with the sub-function to extract the full name of a weekday.

Inputs: Click on the field -> Click on Expression -> Place the below code.

variables('Week days')[sub(outputs('Day_of_Week[Number]'),1)]
Power Automate dayOfWeek() Condition

3. In the same way, save and run the flow manually. After running the flow successfully, open and see the compose outputs, as it will display the weekday name.

  • The return value from the dayOfWeek() function gives the week name (Tuesday).
Microsoft Power Automate flow dayOfWeek()

Get First Day Of Week Name in Power Automate (utcNow)

Here, we will see how to get the first day of the week name [Monday] from utcNow in a Power Automate.

Example: Suppose the current date is “14-12-2023.” Based on the current date, we need to determine the first day of the week, Monday, and retrieve the date that corresponds with that day within the current week.

Power Automate Get First dayOfWeek Name utcNow

Follow the above steps that are mentioned in the above example.

1. Under the trigger, within the ‘Compose‘ flow action, the below-given expression is used to retrieve the first day of the week.

  • Inputs: Select the field -> Click on Expression -> Give the below code.

After that, Click OK.

formatDateTime(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 'dddd')

The ‘1’ represents ‘Monday’ in Microsoft Power Automate dayOfWeek() expression. In the above expression, we can retrieve the date by giving date formats like ‘yyyy-MM-dd’ in the expression.

Power Automate Get First dayOfWeek Name (utcNow)

2. After that, save and manually run the flow to obtain the first day of the current week, Monday, as shown in the screenshot below.

Power Automate start of week dayOfWeek() expression

This is how to get the current week’s first-day name using the Power Automate dayOfWeek() function.

Power Automate Get Day Of Week Number From SharePoint list

In this example, I will use the Power Automate dayOfWeek() function by referencing a SharePoint list in an Automated cloud flow.

Example

I have a SharePoint list [Task List] with a Date column named Task Deadline. This list has various items along with dates, as shown below.

Power Automate condition dayOfWeek()

I want to get the weekday of the SharePoint Date column using Power Automate. Let’s imagine a date “08/12/2023“; it will provide the result of a weekday number representing the particular weekday, like ‘1‘ for Monday.

To achieve it, follow the steps below:

1. Browse make.powerautomate.com in the browser to open the Power Automate Home page. On the Home page, click +Create -> Select Automated cloud flow -> Give flow name and choose the trigger -> Click Create button.

Inside the trigger, provide the below details, as shown in the screenshot.

  • Site Address: Select a site address from the drop-down.
  • List Name: Choose a specific list name from the drop-down.
 dayOfWeek() function in Power Automate

2. After that, initialize the ‘Task Deadline’ column by taking an “Initialized variable” flow action. Set the parameters below.

  • Name: Give the name for the variable as Task Deadline.
  • Type: Select datatype as String from drop-down.
  • Value: Select the field -> Click Expression -> Take ‘Task Deadline’ from the dynamic content.
 dayOfWeek()expression in Power Automate

3. Under the initialized variable, include the dayOfWeek() expression with the variable in the Compose flow action.

Inputs: Select the field -> Click on Expression -> Give the below expression.

After that, Click OK.

dayOfWeek(variables('Day of week'))
 How to use dayOfWeek()expression in Power Automate

4. Then, save and run the flow manually. Now, add an item to the SharePoint list.

Power Automate flow dayOfWeek Number SharePoint list

5. The output will be displayed when the flow runs in the compose flow action. It will give the extracted weekday number as below:

  • The output will be the dayOfWeek number, which is 6, which represents Saturday.
Power Automate dayOfWeek number SharePoint list

This is how to use the Power Automate dayOfWeek() function to get a weekday name and number of a particular date.

Conclusion

I trust you now understand the dayOfWeek() function and its role in Power Automate. In this blog, I covered how to work with the Power Automate dayOfWeek() function, its syntax, and many more like:

  • Get the day-of-week number in Power Automate (utcNow)
  • How to get the day of week name in Power Automate (utcNow)
  • Get Power Automate the first day of week name (utcNow)
  • Power Automate day of week number from the SharePoint list

Also, you may like some more Power Automate tutorials: