• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

Get the date of the following Saturday

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.

JamesNT
0
JamesNT
Asked:
JamesNT
2 Solutions
 
CodeCruiserCommented:
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
                Next
0
 
Jeff CertainCommented:
   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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now