SQL Form query by Year

I'm trying to query a database table based on 2 factors, in my case, Car and Year.

I can do the car which is no problem, but am having difficulty getting the date/year part correct - can anyone please help.

The date format is dd/mm/yy, and I want the user to select a year from a drop down menu, say 2002, then the form show all events for a certain car in the selected year.

My query at the moment is (the date part of which doesn't work) :

SELECT * FROM tblRace
WHERE (CarId =  ::CarId::) AND (RaceDate=::RaceDate::)
ORDER BY RaceDate DESC
CraigBFGAsked:
Who is Participating?
 
webwomanConnect With a Mentor Commented:
You're choosing the year from a dropdown, right? So it's not something that might be entered incorrectly?

Try use this...

SELECT * FROM tblRace WHERE (CarId =  ::CarId::) AND (year(RaceDate)=::RaceDate::)
0
 
hhammashCommented:
Hi,
Are you using Frontpage DRW?

If yes:

Do to your DRW in HTML view
Go to the First grey line
Look for the part where it says Where(.....) And (RaceDate=::RaceDate::) and Change it to (RaceDate=#RaceDate#) then save the page.  You wil see that the SQL in red color has changed.

If you are not using DRW, change the sql to #RaceDate#

Hope it works
hhammash
0
 
CraigBFGAuthor Commented:
Thanks, I got around that problem, but it's the year in particular I want to query by.

tblRace.RaceDate will be dd/mm/yy
#RaceDate# needs to be YYYY

How do I perform such a query?

Craig
0
 
hhammashCommented:
Hi,

Webwoman's SQL will let you do that. Will let you search by year,  even if the year is yy you can entere it as yyyy in the search field.

Regards
hhammash
0
 
CraigBFGAuthor Commented:
This works perfectly, simple when you know how
CJ
0
All Courses

From novice to tech pro — start learning today.