How to Get the Dates for the Current Week in Power Apps

Do you know How to Get the Dates for the Current Week in Power Apps? No problem!

In this Power Apps tutorial, We will discuss how we can retrieve all the dates for the current week in Power Apps. Also, we will see how to get the Day Number of the Current Week in Power Apps.

Additionally, we will get to know how to filter data by the current week in Power Apps with various examples.

Check out: How to use date time picker in PowerApps

How to Get the Dates for the Current Week in Power Apps

In my recent project, I needed to display all the dates for the current week in Power Apps. The current week means the day starts on Monday and ends on Sunday.

My current week starts on 17th July 2023 (Monday) and ends on 23rd July 2023 (Sunday). So based on this, I need to apply the Power Apps formula which will get all the dates of the current week.

In the screenshot below, all represent Power Apps Text label controls including Monday, Tuesday, Wednesday, etc. The current week date values are also displayed in the label controls only.

How to Get the Dates for the Current Week in Power Apps
  • Now to get the dates for the current week in Power Apps, set the Text property of your 7 labels to the following:
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero)),TimeUnit.Days)
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero))+1,TimeUnit.Days)
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero))+2,TimeUnit.Days)
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero))+3,TimeUnit.Days)
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero))+4,TimeUnit.Days)
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero))+5,TimeUnit.Days)
DateAdd(Today(),-(Weekday(Today(),StartOfWeek.MondayZero))+6,TimeUnit.Days)

Where,

  1. DateAdd = Power Apps DateAdd function makes it easier to subtract the calculated number of days from the current date (today).
  2. Today() = This Power Apps function returns the current date.
  3. Weekday(Today())= Today’s weekday number is returned by Weekday(Today()).
  4. StartOfWeek = specify the Start of the week to be MondayZero.
  5. TimeUnit.Days = The result is a whole number of units.
See also  Dataverse Version History

This is how to get the dates for the current week in Power Apps.

Get the Day Number of the Current Week in Power Apps

  • Suppose, in the current week, I have a Monday to Sunday total of 7 days. Where I can consider Monday as 1, Tuesday as 2, Wednesday as 3, and so on.
  • As today is Thursday (07/20/2023), the current weekday number should display as 4 in Power Apps as shown figure below.
Get the Day Number of the Current Week in Power Apps
  • To work around this, insert a Power Apps Text label control and set its Text property to the code below:
Text = "Current Week Day Number:   " & Weekday(
    Today(),
    StartOfWeek.Monday
)

Where,

Current Week Day Number: ” = Message that will appear in the label control

  • If the week starts on Monday, then you need to put StartOfWeek.Monday and if the week starts on Sunday, then you need to put StartOfWeek.Sunday.
  • If you will put StartOfWeek.Sunday, then the output will be 5.
Power Apps Get the Day Number of the Current Week

This is how to get the day number of the current week in Power Apps.

Read: Create PowerApps Date filter

Filter Items By Current Week in Power Apps

Next, we will see how to filter items by current week in Power Apps.

  • My current week is from 07/17/2023 (Monday) to 07/23/2023 (Sunday). So the Power Apps gallery will filter and display only the data of the current week as shown below.
Filter Items By Current Week in Power Apps
  • For this example, I have a SharePoint List named IT Help Desk with various columns. Apart from that, this list has a Date column called Request Date.
  • There are three items that have been requested this current week i.e. 07/19/2023, 07/18/2023, and 07/17/2023.
  • Now I would like to filter all these three items in the Power Apps Gallery Control.
Filter Items By Current Week in Power Apps Gallery
  • Sign in to Power Apps with valid Microsoft credentials.
  • Go to Apps -> Expand + New app -> Select Canvas.
  • Provide the App name and choose the Table Format -> Click on Create.
  • Connect the SharePoint List Datasource connector (IT Help Desk) to the app.
Power Apps Filter Items By Current Week
  • Next, insert a Vertical Gallery Control and set its Layout as Title and subtitle. Also, set its Items property to the code below:
Items = Filter(
    'IT Help Desk',
    'Request Date' >= Today() - Weekday(Today()) + 2 && 'Request Date' <= Today() + (9 - Weekday(Today()))
)

Where,

See also  How to work with dataverse formula column

Request Date‘ = SharePoint Date Column

Filter Data by Current Week in Power Apps

This is how to filter data by the current week in Power Apps.

Moreover, you may also like some more Power Apps tutorials:

This Power Apps tutorial explained how to get all the dates for the current week in Power Apps. Also, we saw how to get the Day Number of the Current Week in Power Apps.

Additionally, we got to know how to filter data by the current week in Power Apps with various examples.

>