?
Solved

SQL Form query by Year

Posted on 2003-03-06
5
Medium Priority
?
137 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:CraigBFG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:hhammash
ID: 8078941
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
 

Author Comment

by:CraigBFG
ID: 8079048
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
 
LVL 19

Accepted Solution

by:
webwoman earned 80 total points
ID: 8083251
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
 
LVL 14

Expert Comment

by:hhammash
ID: 8083356
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
 

Author Comment

by:CraigBFG
ID: 8086921
This works perfectly, simple when you know how
CJ
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question