Link to home
Start Free TrialLog in
Avatar of CraigBFG
CraigBFG

asked on

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
Avatar of hhammash
hhammash

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
Avatar of CraigBFG

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of webwoman
webwoman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
This works perfectly, simple when you know how
CJ