Skip to main content

Notifications

Community site session details
Power Automate - Power Automate Desktop
Answered

Get date of next upcoming Saturday

Like (0) ShareShare
ReportReport
Posted on 19 Oct 2023 18:59:53 by

As part of a PAD flow, I'd like to be able to populate a date field with the date of the next upcoming Saturday. For example, if today is Thursday 10/19/23, I'd like to have PAD input 10/21/23. Would need a solution that would work regardless of current day of week.

Thanks for any help!

  • Verified answer
    Agnius Bartninkas Profile Picture
    10,045 Most Valuable Professional on 20 Oct 2023 at 10:33:18
    Re: Get date of next upcoming Saturday

    An alternative method to what @MichaelAnnis suggested is using the .DayOfWeek property of a date time variable.

    You can build a loop that increases your current date by 1 day and then checks the .DayOfWeek property of the resulting day. If it is equal to Saturday, you can exit the loop.

     

    It would look like this:

    Agnius_1-1697797953200.png

     

    Here's a snippet you can paste into PAD:

    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    LOOP WHILE (CurrentDateTime.DayOfWeek) <> ($'''Saturday''')
     DateTime.Add DateTime: CurrentDateTime TimeToAdd: 1 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> CurrentDateTime
    END
    

     

    Please note that the value of the .DayOfWeek property is localized. So, if your PAD is not English, you need to translate the "Saturday" in the loop to the appropriate name of the day in your language.

     

    When the loop is done, your %CurrentDateTime% variable will hold the next Saturday.

     

    You can also have a separate variable, if you don't want to overwrite %CurrentDateTime%, by adding a single Set variable action before the loop. I just wanted to show you how it can be done with as few actions as possible.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

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

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 161 Super User 2025 Season 1

#2
Riyaz_riz11 Profile Picture

Riyaz_riz11 58 Super User 2025 Season 1

#3
CU12050101-0 Profile Picture

CU12050101-0 34

Overall leaderboard
Loading complete