| Author |
Topic Search Topic Options
|
stevem2003
Newbie
Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
|
Post Options
Thanks(0)
Quote Reply
Topic: Problem with dates Posted: 14 April 2004 at 9:05am |
Hi,
I have an access db with the following fields; dbdate, name1, name2 & id. If the field dbdate holds a date, how can I use ASP to display those records on a particular date? ie. If dbdate = todays date, then display those records
I have tried using Cdate but I'm obviously doing something wrong.
Please Help
Steve
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 9:18am |
|
Correct me if I'm wrong (havent used access for a while). But I think you do SELECT x FROM x WHERE x = #14/4/2004#
|
 |
stevem2003
Newbie
Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 9:30am |
Hi Mart,
Yes that is correct, sorry maybe I assummed too much when asking the question. e.g.
On 14/4/2004 name1 = pete, name2 = steve On 15/4/2004 name1 = mike, name2 = pete.
What I need is a script that will pull data from the database whatever is equal to the current date, as I will have a record for every day of the year.
Many Thanks Steve
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 9:40am |
'You connection stuff goes here strSQL = "Select * from yourtable where dbdate = '#" & date() & "#'" 'Execute that stuff
|
|
|
|
 |
stevem2003
Newbie
Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 10:07am |
Hi,
Using that code I get the following error:-
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression
The line with the error, looks like this:-
rs.open strSQL, conn, 3, 3 |
The whole connection script looks like:-
<% dim conn, rs, strconn, strSQL
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("database.mdb") set conn = server.createobject("adodb.connection") conn.open strconn strSQL = "Select * from roster where dbdate = '#" & date() & "#'" set rs = server.createobject("adodb.recordset") rs.open strSQL, conn, 3, 3 %>
|
What am I doing wrong?
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 10:16am |
|
What's the , 3, 3 all about... Try just with rs.open strSQL, conn.
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 10:18am |
The 3,3 is the cursor position, this part it's OK.
Are you sure that the dbdate field is set as a DATE field in Access? If it is, perhaps it's the single quotes. I think Access works without them.
|
|
|
 |
stevem2003
Newbie
Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
|
Post Options
Thanks(0)
Quote Reply
Posted: 14 April 2004 at 10:22am |
Thanks Zaboss you are right.
Thanks to everybody
|
 |