cancel
Showing results for
Did you mean:
Community Champion

## Solution: Find out Monday's Date

Problem: you want to Filter a Gallery based on data in the current week. You set up two DatePickers to set the start (DatePicker1) and end dates (DatePicker2). However, you want the DefaultDate of DatePicker1 to be the Monday of the current week.

I have a solution for calculating the Monday. Set DatePicker1.DefaultDate to:

```DateAdd(Today(),
If(Weekday(Today())=1,-6,
Weekday(Today())=2,0,
Weekday(Today())=3,-1,
Weekday(Today())=4,-2,
Weekday(Today())=5,-3,
Weekday(Today())=6,-4,
Weekday(Today())=7,-5
)
)```

This formula subtracts the number of days relative to the last Monday and outputs a date.

If you prefer a Sunday, you just need to change the number to subtract, or you could shift the Weekday formula to another mode.

Microsoft Employee
@8bitclassroom
1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps

Try this, it may be simpler:

Today() + 7 - Weekday(Today(), MondayZero)

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff
6 REPLIES 6
Power Apps

Try this, it may be simpler:

Today() + 7 - Weekday(Today(), MondayZero)

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff
Helper II

I tried the following, seems to work aswell 😄

Start of Week

``DateAdd(Today(), -1 * (Weekday(Today(), Monday) - 1), Days)``

End of Week

``DateAdd(Today(), 7 - Weekday(Today(), Monday), Days)``

Responsive Resident

I would like to do something similar.

I would like the date to default to the Monday of the current working week when the user selects a date. For example if they selected the Wednesday of a particular week, a variable would be set containing the date of the Monday for that week.

This is for a time sheet app where the user is using the calendar to select the working week rather than a particular day. In most cases users will select the Monday but I want insurance against selecting other dates as this messes up the presentation of the app.

I have a gallery of days of the week labels that uses the following sequence to generate the week. If gblWeekStart is not set to Monday it messes things up.

``ForAll(Sequence(7), gblWeekStart + Value - 1)``

Super User

@Digital here is an easier way

``Datepicker1.SelectedDate-WEEKDAY(DatePicker1.SelectedDate,2)+1``

This will give you the Monday of any date you feed it

Responsive Resident

@jlindstrom , Perfect. Thank you!

Helper II

I love it how in this thread alone we've listed three methods to retrieve the same value 😄

Announcements

#### Welcome to the User Group Public Preview

Check out how to claim yours today!

Test your skills now with the Cloud Skill Challenge.

#### Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

#### Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (50,556)