Click to See Complete Forum and Search --> : looping in dates


jen
December 20th, 1999, 08:25 AM
Hi!
I have a startdate and stopdate in datetype and I want to "loop" through it and select specific weekdays - say for example all sundays.
Does anyone know how to do that?
Thanks
Jen

Chris Eastwood
December 20th, 1999, 08:39 AM
Here's an example using the VB 'WeekDay' command :


Dim dteOne as date
Dim dteTwo as date
Dim lCount as Long

dteOne = #12/25/1999#
dteTwo = #1/1/2000#

for lCount = dteOne to dteTwo
If Weekday(lCount) = vbSunday then
Debug.print CDate(lCount); " = Sunday"
End If
next





Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb