Skip to main content

Notifications

Community site session details

Community site session details

Session Id : TlE5C3FX87niuPOrI13Kwu
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!

  • Murphys110 Profile Picture
    on 26 Oct 2023 at 19:24:33
    Re: Get date of next upcoming Saturday

    Finally got a minute to try this... and it's INCREDIBLE! Love the simplicity of the solution... Thank you!

  • Murphys110 Profile Picture
    on 26 Oct 2023 at 19:23:39
    Re: Get date of next upcoming Saturday

    Thank you!

  • Nived_Nambiar Profile Picture
    17,575 Super User 2025 Season 1 on 25 Oct 2023 at 16:45:53
    Re: Get date of next upcoming Saturday

    Hello @Murphys110 

     

    Sharing one more easy method for next date calculation using .Net Run script action see below

    Nived_Nambiar_0-1698252030615.png

     

    Inside of .Net run script action

    Nived_Nambiar_1-1698252055473.png

     

    Nived_Nambiar_2-1698252099304.png

     

    Code used 

    Nived_Nambiar_3-1698252116897.png

     

    output_date= CDate(input_date).AddDays(6-Cint(CDate(input_date).DayOfWeek)).ToString("dd\/MM\/yyyy")

     

    The output is 

    Nived_Nambiar_4-1698252148543.png

     

    which is next satuday's date.

     

    Hope this helps !

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • Murphys110 Profile Picture
    on 24 Oct 2023 at 19:16:38
    Re: Get date of next upcoming Saturday

    Many thanks! Will try that as well! 

  • 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.

  • Murphys110 Profile Picture
    on 19 Oct 2023 at 22:31:00
    Re: Get date of next upcoming Saturday

    Wow! I'm off for a couple of days, so will be next week before I can try this out, but thank you! For now I've got it set where I'll just run it on the same day each week, so adding days will be easy... But I much prefer the flexibility your code should provide!

  • MichaelAnnis Profile Picture
    5,721 Super User 2025 Season 1 on 19 Oct 2023 at 20:50:42
    Re: Get date of next upcoming Saturday

    This is a lot, but basically, we establish a known Saturday and then it does a bunch of math to use that known Saturday to find the next Saturday.  I subtract today from the known Saturday to get the days, divide by 7 to get the weeks, truncate that to get just the number of weeks, add 1 so it pushes it to the next Saturday (in weeks), and then add those weeks back to the Known Saturday.  It's good times...code attached (if you aren't familiar, you can copy and paste this code directly in:

    SET KnownSat_mmddyyyy_Slash TO $'''09/30/2023'''
    Text.ConvertTextToDateTime.ToDateTimeCustomFormat Text: KnownSat_mmddyyyy_Slash CustomFormat: $'''MM/dd/yyyy''' DateTime=> KnownSat_Date
    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    DateTime.Subtract FromDate: CurrentDateTime SubstractDate: KnownSat_Date TimeUnit: DateTime.DifferenceTimeUnit.Days TimeDifference=> DaysToKnownSat
    SET WeeksToKnownSat TO DaysToKnownSat / 7
    Variables.TruncateNumber.GetIntegerPart Number: WeeksToKnownSat Result=> RoundedWeeks
    SET WeeksFromKnowSat TO RoundedWeeks + 1
    DateTime.Add DateTime: KnownSat_Date TimeToAdd: WeeksFromKnowSat * 7 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> NextSat

    Should look like this after you paste:

    MichaelAnnis_0-1697748702914.png


    Best of luck!



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…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 18 Super User 2025 Season 1

#2
Nived_Nambiar Profile Picture

Nived_Nambiar 10 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 6

Overall leaderboard
Loading started
Loading complete