Click to See Complete Forum and Search --> : Comparing times and dates...
artsapimp
Dec 7th, 2000, 09:51 AM
I am building a calendar and have ideas that I don't know how to build. I have the basic functionality pulling from a database and so on to make the calendar work. What I want to do is make the home page automatically pull up the next 4 hours of schedules and display them on the page. I'm sure there is something that compares Now to the database, but I don't know how to do it. Please assist with that if you can. Thanks.
You could do something like this:
Dim dteStart
Dim dteEnd
dteStart = Now()
dteEnd = DateAdd("h", 4, dteStart)
To get your starting and ending dates/times and then use some SQL on your database that looked like this:
' SQL Server:
Set rstSchedule = conYourConnection.Execute("SELECT * FROM YourScheduleTable WHERE YourScheduleTablesDateField BETWEEN '" & dteStart & "' AND '" & dteEnd & "'")
' Access (97):
Set rstSchedule = conYourConnection.Execute("SELECT * FROM YourScheduleTable WHERE YourScheduleTablesDateField BETWEEN #" & dteStart & "# AND #" & dteEnd & "#")
Good luck,
Paul
artsapimp
Dec 7th, 2000, 10:28 AM
That's exactly what I was looking for. Thanks
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.