Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populating an array of dates with a start and an end date. VB.NET 2008

    Hi -

    I'm trying to find a good way to do this, and I'm hoping someone here might be able to point me in the right direction. I've created an array called "myDates" to hold all the dates I want my sub to operate on, but I'm having a hard time populating it. I need to cycle through all the dates between a user selected "begin" and "end" date, which are hosted in DateTimePicker2 and DateTimePicker3 respectively (and also converted out to myMonth / Day / Year and endMonth / Day / Year as integers). Here's an idea of what I've done so far (which is really just setting up a framework to determine what I will handle):

    Code:
            Dim myDates(101) as Date
    
            ' We need to work out how many days we are working with here.
    
            If endYear > myYear Then
    
                ' we are spanning more than one year
                If endMonth > myMonth Then
                    ' we are spanning more than one month (ie, Jan 2008 - Feb 2009)
                    MsgBox("Error! Did you select more than 100 days?")
    
                ElseIf endMonth < myMonth Then
                    ' we are spanning more than one year, and the month is lower (ie, Dec 2008 - Jan 2009)
                    ' MOST NORMAL SITUATION
    
                    Dim offset As New DateTimeOffset
    
                    For diq = 0 To 100
                        myDates(0) = DateTimePicker2.Value.Date + (SINGLE DAY CONSTANT GOES HERE MAYBE ?? )
                    Next
    
                Else
                        ' we are spanning multiple years but the month is the same (ie, Jan 2008 - Jan 2009)
                        MsgBox("Error! Did you select more than 100 days?")
    
                End If
            End If
    So the short version of the question is: does anyone know of a constant that can be used to refer to a single day? Or on the flip side, is there just a much better way to do this that I'm missing?

    Thanks in advance for any help!

  • #2
    New Coder
    Join Date
    Jul 2008
    Location
    New York
    Posts
    24
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Arrow

    Try this out:

    http://boonedocks.net/.../137-Creating-a-Date-Range-Array-with-PHP.html

    Just change the format YYYY-MM-DD to what ever you need it to be, hope it helps!

    Trevor


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •