Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Comparing Dates through Query
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Comparing Dates through Query

 Post Reply Post Reply
Author
gupta_ji View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2003
Location: India
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote gupta_ji Quote  Post ReplyReply Direct Link To This Post Topic: Comparing Dates through Query
    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.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2004 at 4:19pm
Instead of quotation marks you use hash's (#) I think
Back to Top
gupta_ji View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2003
Location: India
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote gupta_ji Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2004 at 4:22pm
No it did not help
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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



Edited by ljamal
Back to Top
gupta_ji View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2003
Location: India
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote gupta_ji Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2004 at 11:05am

Thanks Ijamal. Your trick worked for me.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.