Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Date Filter 1

Status
Not open for further replies.

MattGreer

Technical User
Feb 19, 2004
471
0
0
US
I searched and I feel so ignorant... I'm trying to filter a list of songs that were performed this calendar year. Here's the query:

This one works but doesn't filter by date:
SQL:
SELECT tblSongs.Title, tblEvents.Date
FROM tblSongs INNER JOIN (tblEvents INNER JOIN tblHistLink ON tblEvents.EventID = tblHistLink.EventID) ON tblSongs.SongID = tblHistLink.SongID
ORDER BY tblEvents.Date DESC , tblSongs.Title, tblEvents.Date;

Here I tried to filter using =Year(Now())
SQL:
SELECT tblSongs.Title, tblEvents.Date
FROM tblSongs INNER JOIN (tblEvents INNER JOIN tblHistLink ON tblEvents.EventID = tblHistLink.EventID) ON tblSongs.SongID = tblHistLink.SongID
WHERE (((tblEvents.Date)=Year(Now())))
ORDER BY tblEvents.Date DESC , tblSongs.Title, tblEvents.Date;

Here I tried to filter using =Year(Date())
SQL:
SELECT tblSongs.Title, tblEvents.Date
FROM tblSongs INNER JOIN (tblEvents INNER JOIN tblHistLink ON tblEvents.EventID = tblHistLink.EventID) ON tblSongs.SongID = tblHistLink.SongID
WHERE (((tblEvents.Date)=Year(Date())))
ORDER BY tblEvents.Date DESC , tblSongs.Title, tblEvents.Date;

Obviously the last two returned empty results.

I feel so dumb. I appreciate your help!!



Thanks!!


Matt
 
Hi,
Code:
WHERE YEAR(tblEvents.Date)=Year(Date)

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
It's funny, when I just looked at the SQL I realized what the problem was but I still didn't know what the right syntax would be. You're amazing Skip. Is there anything you don't know??? :)



Thanks!!


Matt
 
Oh, yes. Lots anf lots!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Well shoot, I just got around to implementing your fix, and I'm getting the whole list and not just the songs that we performed this calendar year.

SQL:
SELECT tblSongs.Title, tblEvents.Date
FROM tblSongs INNER JOIN (tblEvents INNER JOIN tblHistLink ON tblEvents.EventID = tblHistLink.EventID) ON tblSongs.SongID = tblHistLink.SongID
WHERE (((Year([tblEvents].[Date]))=Year([Date])))
ORDER BY tblEvents.Date DESC;

Not sure... what to fix...

Thanks!!


Matt
 
Hey, I figured it out! I used

Code:
WHERE (((Year([tblEvents].[Date]))=Year(Now())))

Thanks!!


Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top