Author |
Topic  |
|
skyhawks
Junior Member
 
USA
125 Posts |
Posted - 26 February 2002 : 17:22:51
|
i want to output one record from my access database based on the today's date. another word, in recordID #1 -- 2/25/2002(startdate) and 3/3/2002(enddate); recordID #2 -- 3/4/2002 (startdate) and 3/8/2002(enddate). today's date is 2/26/2002. it will output recordID #1. I got so lost doing the date thing. can anyone help me out.
<% dim conn dim rs dim strsql
set conn = server.createobject("adodb.connection") conn.open "newyorkdb" set rs = server.createobject("adodb.recordset") strsql = "SELECT * FROM trivia WHERE startdate" rs.open strsql, conn recordID = rs("recordID") question = rs("question") choice1 = rs("choice1") choice2 = rs("choice2") choice3 = rs("choice3") choice4 = rs("choice4") answer = rs("answer") startdate = rs("startdate") enddate = rs("enddate")
answer = Replace(answer, vbCrLf, "<br>")
%>
<%= recordID %><br> <%= question %><br> <%= choice1 %><br> <%= choice2 %><br> <%= choice3 %><br> <%= choice4 %>
<p><%= answer %>
|
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
Posted - 26 February 2002 : 18:01:45
|
how are the dates stored in the db?
Like in snitz: 20001224000000 Or 26/02/2002?
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
 |
|
skyhawks
Junior Member
 
USA
125 Posts |
Posted - 26 February 2002 : 18:17:24
|
the date in my database is being stored as 2/25/2002
|
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
|
skyhawks
Junior Member
 
USA
125 Posts |
Posted - 27 February 2002 : 14:31:12
|
hmmm, i didnt work.
sky
firstDate = ( Request.Form("startDate") ) lastDate = ( Request.Form("endDate") )
set conn = server.createobject("adodb.connection") conn.open "newyorkdb" set rs = server.createobject("adodb.recordset") strsql = "SELECT * FROM trivia WHERE " & DateAdd("d", 0, Date) & " BETWEEN #" & firstdate & "# AND #" & lastdate & "#"
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 27 February 2002 : 14:40:57
|
quote:
hmmm, i didnt work.
sky
firstDate = ( Request.Form("startDate") ) lastDate = ( Request.Form("endDate") )
set conn = server.createobject("adodb.connection") conn.open "newyorkdb" set rs = server.createobject("adodb.recordset") strsql = "SELECT * FROM trivia WHERE " & DateAdd("d", 0, Date) & " BETWEEN #" & firstdate & "# AND #" & lastdate & "#"
Am I missing something or is there is a field name missing in the WHERE clause: ?!
strsql = "SELECT * FROM trivia WHERE MyFieldName BETWEEN #" & firstdate & "# AND #" & lastdate & "#"
I didn't understand the thing with the current date. I'm addmiting that your firstdate and lastdate give you the time interval you want. But regardless of what you do you have to apply a criteria to a fieldname in a WHERE clause.
Edited by - ruirib on 27 February 2002 14:44:10 |
 |
|
skyhawks
Junior Member
 
USA
125 Posts |
Posted - 27 February 2002 : 14:55:40
|
yea, something is wrong....
in my access database, each record contain a startdate and an enddate. what that means is i wanted to output that record based on the startdate. so its like saying, if the current date is between and equal to the startdate and enddate, it will display that record only.
|
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 27 February 2002 : 16:13:49
|
strsql = "SELECT * FROM TRIVIA WHERE STARTDATE <= #" & DATE() & "# AND LASTDATE >= #" & DATE() & "#"
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 27 February 2002 16:16:27 |
 |
|
skyhawks
Junior Member
 
USA
125 Posts |
Posted - 27 February 2002 : 16:28:48
|
thanks GauravBhabu & ruirib
Both of your method work good. =)
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 27 February 2002 : 16:35:20
|
Glad it did. I deleted my post as Gaurav had posted a good solution before me, that I found only after posting mine, and there is no point in having duplicate posts.
|
 |
|
|
Topic  |
|