How to get the list of sundays between 2 specified dates?

JCel

Active member
Joined
Jun 15, 2009
Messages
30
Programming Experience
Beginner
Hi there,

I dont know How to get the list of sundays between 2 specified dates?

for ex. i want to get all the saturday / sunday or any days, dates between 10-10-2009 to 31-10-2009(the date selection is done with the help of DateTimePicker Control)

now my desired output is:
11-10-2009
18-10-2009
25-10-2009

How could I get this?
 
VB.NET:
        Dim StartDate As New Date(2009, 10, 10)
        Dim EndDate As New Date(2009, 10, 31)
        Dim WhichDateToCheck As Date = StartDate
        While WhichDateToCheck <= EndDate
            If WhichDateToCheck.DayOfWeek = DayOfWeek.Sunday Then
                'do Sunday code here
            End If
            WhichDateToCheck = WhichDateToCheck.AddDays(1)
        End While
 
Are your weeks on your planet a variable number of days long, inertia? :)
VB.NET:
        Dim sundays as New List(Of DateTime)
        Dim StartDate As New Date(2009, 10, 10)
        Dim EndDate As New Date(2009, 10, 31)
        Dim WhichDateToCheck As Date = StartDate
        While WhichDateToCheck <= EndDate AndAlso WhichDateToCheck.DayOfWeek != DayOfWeek.Sunday 
            WhichDateToCheck = WhichDateToCheck.AddDays(1)
        End While
        While WhichDateToCheck <= EndDate
          sundays.Add(WhichDateToCheck)  
          WhichDateToCheck = WhichDateToCheck.AddDays(7)
        End While
 
Are your weeks on your planet a variable number of days long, inertia? :)

VB.NET:
Dim PlanetWeek as DateTime = WorkToBeCompleted / (AmountOfSleepPeriods * CaffeineConsumption)

;)
 
Back
Top