You are currently viewing PowerApps get day of week date
1 / 1 – PowerApps get date of the acurrent week day.png

PowerApps get day of week date

  • Post author:
  • Post category:Power Apps
  • Reading time:10 mins read

In this blog post, we will learn how PowerApps get day of week date for example get the date of every Saturday in the current week.

We will learn

  • How to use the PowerApps WeekDay function
  • How PowerApps get the date of a day in the Current week?
  • Learn How to use the PowerApps DateAdd function?

powerApps get day of week

For these example the Default start of the week is Sunday and ends on

powerApps Week Day Function

In Power Apps, you can use the Weekday function to get the day of the week for a specific date. The Weekday function returns a number representing the day of the week depending on the Start of the week, for example if not specified the start of the week, then the week starts at Sunday then Sunday is represented by 1, Monday by 2, Tuesday by 3, Wednesday by 4 Thursday by 5 Friday by 6 Saturday by 7.

And if the week start at Monday then Monday by 1, Tuesday by 2, Wednesday by 3 and so on. So the return value of the Week day will depend on The start of the week.

Syntax:

Weekday( DateTime [, StartOfWeek ] )
  • DateTime . Date/Time value to operate on and it is required.
  • StartOfWeek – . Excel code specifying which day starts the week. If not supplied, 1 (Sunday first) is used. and it is optional

Example1:

Weekday(Today()) 
the output is: 1  today is Sunday and it is the Default start of week as Iam not specified the function

Example2:

Weekday(Today(),StartOfWeek.Monday)
Output will be 7 as today is Sunday and it the here the last day of the week that start with Monday

This is how PowerApps WeekDay Function work. Now lets learn how to get the date of a specific day in the current week in PowerApps.

How to get the Current week day date in PowerApps

To get the current week day date in Power Apps, you can use the Today() function along with the Weekday() function. Here’s examples formula to achieve this:

Example 1:

In this example we will return the date of the current week Sunday in case of the start of the week is the default “Sunday”

Todays date is 6/4/2023

DateAdd(Today(), 1 - Weekday(Today()), TimeUnit.Days)
PowerApps get day | Power Platform Geeks
  • Today() returns the current date.
  • Weekday(Today()) returns the weekday number of the current day, where Sunday is the start of the week and represented by 1, Monday by 2, and so on.
  • 1 - Weekday(Today()) subtracts the weekday number of the current day from 1, This will give us the number of days to subtract from the current date to reach the previous Sunday.
  • DateAdd(Today(), 1 - Weekday(Today()), TimeUnit.Days) subtracts the calculated number of days from the current date to obtain the first day (Sunday) of the current week.
  • uses the DateAdd function to subtract the calculated number of days from the current date (Today). This effectively moves the date back to the previous Sunday.
  • So, the overall result of this formula is the date value representing the previous Sunday relative to the current day ” date of the current week day” in PowerApps.

You can replace the Today Function with any valid Date

Example 2:

In this example we will return the date of the current week Monday but in this case we will specify the Start of the week to be Monday

Todays date is 6/4/2023

DateAdd(Today(), 1 - Weekday(Today(),StartOfWeek.Monday), TimeUnit.Days)
powerapps get day of week

Example 3:

In this example we will return the date of the current week Thursday and the start of the week is Sunday

DateAdd(Today(), 1-Weekday(Today())+4,TimeUnit.Days)

We add 4 that represent the number of days till Thursday 5-1=4 ” % the day number of thursday and 1 is the day number of Sunday”

PowerApps get day 1 | Power Platform Geeks

Example 4:

In this example we will return the date of the current week Friday and the start of the week is Monday

DateAdd(Today(), 1-Weekday(Today(),StartOfWeek.Monday)+4,TimeUnit.Days)
PowerApps get day 2 | Power Platform Geeks

The return date is 6/2/2023 as the week start at Monday and ends at Sunday and today is Sunday ” 6/4/2023″ on my calendar

We add 4 that represent the number of days till Friday 5-1=4 ” % the day number of Thursday and 1 is the day number of Monday”

If you need to get the current date of Thursday add 3 and 2 for Wednesday and so on

In conclusion, you can use the DateAdd() and Weekday() functions in Power Apps to obtain the current week day date. By subtracting the weekday number of the current day from the current date and using the DateAdd() function, you can calculate the date of the first day (Sunday) of the current week. This provides you with a way to dynamically retrieve the current week day date in Power Apps.

See Also
Join us

Heba Kamal

Microsoft MVP, MCT, Technical Speaker, Blogger, and Microsoft 365 and Power Platform Consultant.