Print Page | Close Window

Problem with dates

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9993
Printed Date: 31 March 2026 at 6:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Problem with dates
Posted By: stevem2003
Subject: Problem with dates
Date 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



-------------
There's no point running if you're on the wrong road!



Replies:
Posted By: Mart
Date 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#


Posted By: stevem2003
Date 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



-------------
There's no point running if you're on the wrong road!


Posted By: michael
Date Posted: 14 April 2004 at 9:40am

'You connection stuff goes here
strSQL = "Select * from yourtable where dbdate = '#" & date() & "#'"
'Execute that stuff


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: stevem2003
Date 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?



-------------
There's no point running if you're on the wrong road!


Posted By: Mart
Date Posted: 14 April 2004 at 10:16am
What's the , 3, 3 all about... Try just with rs.open strSQL, conn.


Posted By: zaboss
Date 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.



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: stevem2003
Date Posted: 14 April 2004 at 10:22am

Thanks Zaboss you are right.

Thanks to everybody



-------------
There's no point running if you're on the wrong road!


Posted By: jatherton
Date Posted: 14 April 2004 at 8:19pm
Just a suggestion, but something I did was add a publish_date and expire_date field in my table. 

When I created the SQL statement I just told it to include any record in the table when todays date was greater than or equal to the publish date AND less than or equal to the expire date.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net