Given a Date or DateTime, the DayOfWeek property gives a text value eg. Friday, whereas I need the integer value. Where is that?
What Im trying to do is get the Sunday date for the current week, so I supposed it would be:
CurrentDate - DayOfWeek
dayOfWeek() actually does return an integer. Sunday is 0 and Saturday is 6
If you are looking for the previous Sunday, see my example below:
Sorry I wasnt clear, this is regarding PAD - power automate desktop
Datatype properties - Power Automate | Microsoft Docs
|Year||The year part of the datetime value.|
|Month||The month part of the datetime value.|
|Day||The day part of the datetime value.|
|DayOfWeek||The name of the day (Sunday, Monday etch).|
|DayOfYear||The day of the year part of the datetime value (1-365/6).|
|Hour||The hour part of the datetime value.|
|Minute||The minute part of the datetime value.|
The seconds part of the datetime value.
Here is some input from other users: https://powerusers.microsoft.com/t5/General-Power-Automate/Power-Automate-Cloud-vs-Desktop/td-p/7924...
Personally, I think PAD is easier to use, bot the online version has more capability, such as triggers being able to occur from online activity. Ex. it taps into your outlook and says "when I receive an e-mail from so-and-so, do this."
In PAD, you would have to trigger the flow manually (or schedule a flow to run systematically), and you could say, "check all unread messages for an e-mail from so-and-so, and do this."
So, PAD is a little limited in that manner. I think the best is to learn both. PAD might be better to learn first to take care of your local processes on your own workstation.
You might find this interesting too; it was for "last Friday", but you could easily change that to "last Sunday", if you always need last Sunday's date.
There are many ways to accomplish this, and one is using the power of Powershell.
You can feed the "run powershell scupt" with any date and get the weeknumber.
Dateformat to feed the powershell script is MM/dd/yyyy
I am currently experiencing the same problem in PAD where I need to find the numeric week we are in. An out of the box solution I might go for is to visit a website like https://www.epochconverter.com/weeknumbers and spy the week number as a UI element. You could try the same with the day number..
Get Current Date Time
Date to Text Custom format 01/01/yyyy to %BDTY_mmddyyyy_Slash% (stands for beginning day this year)
Text to Date %BDTY_mmddyyyy_Slash% custom format mm/dd/yyyy to %BDTY%
Subtract Dates (CurrentDateTime - %BDTY%) to %Days% 'days in this year'
Set %Weeks_frac% to %Days / 7%
Truncate number %Weeks_frac% using Get integer part to %Weeks_rounddown%
Set %CurrentWeek% to %Weeks_rounddown + 1%
So, this will work depending on how you want to calculate the first week of the year, if 01/01 to 01/07 is the first week, then this will do. If you want your week to start on a Monday, and any portion of the beginning of the year still counts as the first week, then I would pick the first Monday before 1/1, and change the second line:
from: Date to Text Custom format 01/01/yyyy to %BDTY_mmddyyyy_Slash% (stands for beginning day this year)
to: Set %BDTY_mmddyyyy_Slash% to 12/27/2021
Note: as it stands here, you will have to change that start date each year if you choose this path, or figure out a new logic to define the first Monday before the first of the year. It can be done, but it's a little more involved.
Just found out about a more straightforward solution to get the current day:
1) Use the 'Get current date and time" action
2) Set a variable which retrieves the "Day Of Week" on the first action's variable
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Join us on June 28 for our monthly User Group leader call!
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!