December 28, 2024

The dayOfWeek Function will return an integer number that represents the day of the week for a date, where 0 is Sunday, 1 is Monday ending in 6, a Saturday.

Usage

It follows a simple pattern.

  1. Date

Example:

dayOfWeek('2019-10-28T10:10:00Z')

will return 

1
So we know it's a Monday

Please be aware that the reference material, Microsoft names objects like ‘2019-10-28T10:10:00Z’ as timestamps. I prefer calling them “Date” to avoid confusion with the UNIX timestamp, commonly used in APIs, to represent the number of seconds elapsed since Jan 01 1970 (UTC).

Limitations

Since it returns an integer, you need to provide the translation to something that the end-user will understand. It can be tricky for apps in multiple languages but always translate the value. The user doesn’t know that 0 means Sunday.

Contrary to SharePoint and Power Apps, there’s no limitation to the date that you can use. You can do things like:

dayOfWeek('1000-12-30T00:00:00Z')

and you'll get 

2
So we know it's a Tuesday

Recommendations:

  1. In some cultures the first day of the week is Monday and not Sunday, so one would expect 0 to be Monday. Don’t do any math in trying to convert to your preferred system. Just translate the value provided, and you’re good to go.
  2. To get the best results, please be sure that you’re passing a date that is UTC. If you’re storing somewhere your local time, use the “Convert Time Zone” action to convert it before providing the value to the dayOfWeek Function. If you don’t do it, you may be returning invalid values to the end-user.

Sources:

Microsoft’s addMinutes Function Reference

Back to the Power Automate Function Reference.

Featured Image by Charles 🇵🇭 on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

One thought on “Power Automate: dayOfWeek Function

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon