web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get date of next upcom...
Power Automate
Answered

Get date of next upcoming Saturday

(0) ShareShare
ReportReport
Posted on 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!

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    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!



  • Murphys110 Profile Picture
    on at

    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!

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    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 at

    Many thanks! Will try that as well! 

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    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 at

    Thank you!

  • Murphys110 Profile Picture
    on at

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 245

#2
David_MA Profile Picture

David_MA 216 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 212

Last 30 days Overall leaderboard