Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 outputing a record based on today's date..???
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

skyhawks
Junior Member

USA
125 Posts

Posted - 26 February 2002 :  17:22:51  Show Profile  Visit skyhawks's Homepage
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  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
how are the dates stored in the db?

Like in snitz: 20001224000000
Or 26/02/2002?

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 26 February 2002 :  18:17:24  Show Profile  Visit skyhawks's Homepage
the date in my database is being stored as 2/25/2002

Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 27 February 2002 :  02:19:57  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
if i understand right then this should work...

strsql = "SELECT * FROM trivia WHERE " & DateAdd("d", -1, Date)

So if todays date is 2/27/02 then will pull up with the date of 2/26/02

Brad
Web Hosting with SQL Server @ $24.95 per month
Snitz Mod Archive

Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 27 February 2002 :  14:31:12  Show Profile  Visit skyhawks's Homepage
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 & "#"



Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 27 February 2002 :  14:40:57  Show Profile  Send ruirib a Yahoo! Message
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
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 27 February 2002 :  14:55:40  Show Profile  Visit skyhawks's Homepage
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.

Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 27 February 2002 :  16:13:49  Show Profile
 
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
Go to Top of Page

skyhawks
Junior Member

USA
125 Posts

Posted - 27 February 2002 :  16:28:48  Show Profile  Visit skyhawks's Homepage
thanks GauravBhabu & ruirib

Both of your method work good. =)




Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 27 February 2002 :  16:35:20  Show Profile  Send ruirib a Yahoo! Message
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.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.44 seconds. Powered By: Snitz Forums 2000 Version 3.4.07