Print Page | Close Window

Comparing Dates through Query

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=11895
Printed Date: 31 March 2026 at 1:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Comparing Dates through Query
Posted By: gupta_ji
Subject: Comparing Dates through Query
Date Posted: 21 September 2004 at 4:11pm
I am using MS Access Database. "Followdate" is a DATE field in this database. I want to search records where the date is less than any specified date.

Followdate=request.form("date")

sql = "select * from followquery where followdate<='" & followdate & "' "

I am getting this error

Microsoft JET Database Engine error '80040e07'
Data type mismatch in criteria expression.

Can body correct my Query.


-------------
http://www.sgrj.com" rel="nofollow - chartered accountants India , http://www.delhiprofessionals.com" rel="nofollow - accounting Outsourcing ISO Certification



Replies:
Posted By: Mart
Date Posted: 21 September 2004 at 4:19pm
Instead of quotation marks you use hash's (#) I think


Posted By: gupta_ji
Date Posted: 21 September 2004 at 4:22pm
No it did not help

-------------
http://www.sgrj.com" rel="nofollow - chartered accountants India , http://www.delhiprofessionals.com" rel="nofollow - accounting Outsourcing ISO Certification


Posted By: michael
Date Posted: 21 September 2004 at 5:15pm
I'm not an access guru but quotes may work around it, besides that always, always check your values before performins database operations. Use CDate(Followdate) to format it correctly and IsDate(Follwodate) as Boolean to make sure a valid date has been submitted.
If IsDate(followdate) Then
'Perform DB Operation
ELSE
Response.Write("not a date")
END IF

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


Posted By: ljamal
Date Posted: 21 September 2004 at 7:48pm
This should do the trick


Followdate=request.form("date")

if IsDate(followdate) then
sql = "select * from followquery where followdate<=#" & followdate & "# "
end if



-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: gupta_ji
Date Posted: 23 September 2004 at 11:05am

Thanks Ijamal. Your trick worked for me.



-------------
http://www.sgrj.com" rel="nofollow - chartered accountants India , http://www.delhiprofessionals.com" rel="nofollow - accounting Outsourcing ISO Certification



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