|
-
Apr 15th, 2003, 09:15 AM
#1
Thread Starter
Hyperactive Member
[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
Last edited by ashay; Apr 15th, 2003 at 09:31 AM.
"If you should die before me, ask if you could bring a friend."
- Stone Temple Pilots
-
Apr 15th, 2003, 09:23 AM
#2
Let me in ..
Re: Date Ranges Problem........
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.
-
Apr 15th, 2003, 09:25 AM
#3
Try this
VB Code:
private sub DateReturn (Date1 as date, Date2 as date)
dim Counter as integer
if Date1 < Date2 then
msgbox "Error Date1 lies before date2!!"
exit sub
end if
counter = 1
while notl Date1 = Date2
Date1 = dateadd("d",1,date1)
msgbox Date1
wend
This should work, haven't tested it. But the idea should be clear
-
Apr 15th, 2003, 09:29 AM
#4
Thread Starter
Hyperactive Member
hi techyspecy n Lightning,
thanxxxxxxxxxxxxxxxxxxxxxxxxx a lot........ 
regds,
ashay
"If you should die before me, ask if you could bring a friend."
- Stone Temple Pilots
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|