Skip to main content

Notifications

Community site session details

Community site session details

Session Id : dTodPBwcDXtYFleBUfTo+b
Power Apps - Building Power Apps
Answered

Solution: Find out Monday's Date

Like (2) ShareShare
ReportReport
Posted on 16 Oct 2016 04:45:14 by 3,976

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.

Categories:
  • jaxkookie Profile Picture
    18 on 22 Mar 2022 at 14:32:52
    Re: Solution: Find out Monday's Date

    @opticshrew2 

    can you explain the start of week formula? why do we multiple by -1 and then subtract 1?

    thanks

  • opticshrew2 Profile Picture
    117 on 28 Jul 2020 at 08:00:21
    Re: mRe: Solution: Find out Monday's Date

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

  • Digital Profile Picture
    1,207 on 28 Jul 2020 at 02:17:25
    Re: mRe: Solution: Find out Monday's Date

    @jlindstrom , Perfect. Thank you!

  • Joel CustomerEffective Profile Picture
    3,224 on 28 Jul 2020 at 02:13:17
    Re: mRe: Solution: Find out Monday's Date

    @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 

  • Digital Profile Picture
    1,207 on 28 Jul 2020 at 01:01:40
    mRe: Solution: Find out Monday's Date

    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)

     

  • opticshrew2 Profile Picture
    117 on 20 Jul 2020 at 15:01:22
    Re: Solution: Find out Monday's Date

    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)

     

  • Verified answer
    rgruian Profile Picture
    on 17 Oct 2016 at 20:22:51
    Re: Solution: Find out Monday's Date

    Try this, it may be simpler:

     

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

     

    I hope this helps.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,731 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,077 Most Valuable Professional

Leaderboard