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.
It follows a simple pattern.
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).
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
- 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.
- 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.
Microsoft’s addMinutes Function Reference
Back to the Power Automate Function Reference.
Featured Image by Charles 🇵🇭 on Unsplash
One thought on “Power Automate: dayOfWeek Function”
Also if anyone needs to get the date of the next monday, tuesday, friday, saturday… etc. Then you can use this example flow to continually get the date of any upcoming day of the week https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Date-of-Next-Chosen-Day-of-Week/td-p/1466540