Get a list of dates using start date and end date range

Jiggy

New member
Joined
Dec 1, 2011
Messages
2
Programming Experience
1-3
Hi

I am trying to get a list of dates from a provided StartDate and EndDate in my database, and use these dates to link to dates in a database (to display another variable on the y-axis of the chart) and to populate the x-axis of a chart (with the list of dates).
Is it possible to get a list of dates in VB and pass them into a chart this way?

Thanks
 
I don't know about the chart part as I really haven't used the chart control but, to get a list of dates:
Dim startDate = #11/1/2011#
Dim endDate = Date.Today

Dim dates = Enumerable.Range(0, 1 + CInt((endDate - startDate).TotalDays)).
                       Select(Function(n) startDate.AddDays(n)).
                       ToArray()

For Each d As Date In dates
    MessageBox.Show(d.ToShortDateString())
Next
 
jmcilhinney

Thanks for that, it gets the dates correctly. I am using the dates from this array to match to dates in my database, where they exist. From this join I will get an 'hours' figure for each date that matches. What's the best way to match these up? Would I have to use the array to get a variable for each date?
 
Back
Top