[RESOLVED]Date Ranges Problem........
hi,
I need to find the dates between a range of dates......
eg:
the dates are in dd/mm/yyyy format
the user specifies 2 dates
Date1:15/4/2003
Date2:20/4/2003
I want to retrieve the dates between Date1 and Date2.i.e.
15/4/2003,16/4/2003,17/4/2003,18/4/2003,19/4/2003,20/4/2003
It is easy to retrive the dates of the same month...but probs arise when date1 and date2 are of different months.....n more probs for diff years......
any suggestions or examples highly appreciated......
regds,
ashay
Re: Date Ranges Problem........
Quote:
Originally posted by ashay
hi,
I need to find the dates between a range of dates......
eg:
the dates are in dd/mm/yyyy format
the user specifies 2 dates
Date1:15/4/2003
Date2:20/4/2003
I want to retrieve the dates between Date1 and Date2.i.e.
15/4/2003,16/4/2003,17/4/2003,18/4/2003,19/4/2003,20/4/2003
It is easy to retrive the dates of the same month...but probs arise when date1 and date2 are of different months.....n more probs for diff years......
any suggestions or examples highly appreciated......
regds,
ashay
Create a new form and add a listbox to it...
VB Code:
Option Explicit
Private Sub Form_Load()
Dim l_dtStartDate As Date
Dim l_dtEndDate As Date
l_dtStartDate = Now
l_dtEndDate = DateAdd("yyyy", 1, l_dtStartDate)
MsgBox l_dtStartDate
MsgBox l_dtEndDate
Dim i As Long
Dim l_dtTempDate
While l_dtStartDate <= l_dtEndDate
List1.AddItem l_dtStartDate
l_dtStartDate = DateAdd("d", 1, l_dtStartDate)
Wend
End Sub
This will fill all the dates in the listbox between today and year from today. You can change the Start and End date for different results.