Get the date of the following Saturday

Posted on 2011-04-26
Last Modified: 2012-05-11
I need a function that will get the date of the following Saturday regardless of what day of the week the system date currently is.  

So if the current date is 4/26/2011 then it will get 4/30/2011.
If the current date is 5/6/2011 then it will get 5/7/2011.

This function should provide the date only, no time included.

If the current system date is a Saturday, it will provide the date of the next Saturday.

The date should be in the format of 5/7/2011 as an example.

Question by:JamesNT
    LVL 83

    Accepted Solution

    Try this

                    Dim dDate As Date = Today
                    For I As Integer = 1 To 6
                        If dDate.AddDays(I).DayOfWeek = DayOfWeek.Saturday Then
                            Return dDate.AddDays(I)
                            Exit For
                        End If
    LVL 24

    Assisted Solution

    by:Jeff Certain
       Public Function FindNextSaturday(ByVal inputDate As Date) As Date
            Dim daysToAdd As Integer = DayOfWeek.Saturday - inputDate.DayOfWeek
            If daysToAdd < 0 Then daysToAdd += 7

            Return inputDate.AddDays(daysToAdd)
        End Function

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now