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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QUERY THAT LOOKS FOR PRESENT YEAR VALUE 2

Status
Not open for further replies.

goober84

Technical User
Apr 8, 2010
3
CA
I have searched the forums and couldnt find this and i am sorry if this has already been posted. I have a query, that looks at a table. The table has a date field, in the format of mm/dd/yyyy. I want the query to only find records that equal the present year, i.e. this year it will only select records with 2010. I am rather proficient in Access, and i know this is a stupid and probably easy expression, i just cant get it. thank you for your help
 
SELECT ...
FROM ...
WHERE Year([date field])=Year(Now())

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You should post your question here:
forum701

But basically, the easiest way is to compare the dates. If you're wanting to use the Query Design tool in Access, then put these in your "criteria" for your date field:
Code:
>#12/31/2009# And <#1/1/2011#
 
Yeah, my method is looking at a static year, whereas PHV's value will be more of a dynamic filter, where it would be always looking for "this year" rather than specifically 2010... so in 2015, it'd be looking at 2015.
 
Thank you both very much. I am rather familiar with doing it your way kjv,but i was looking for it to not be in a static manner, or even a user input field where i had them enter the year, i was looking for it to always just look at the present year, but i really thank both of you for a very quick response, i am new to the forum.
 
BTW, Thank you PHV, that worked perfect.
 
goober84,

If you look in each of the posts, you can make it known that a post was helpful to you by clicking on "Thank <name> for this valuable post!" So, if PHV's solution worked for you, that'd be a way of making it known.

Also, for future reference, in the following search results, you'll see some various FAQ postings on how to get the best answers on tek-tips. Feel free to read through them, I'd suggest that any one will basically tell you what you need to know from a general sense. I don't think there will be much variance from one forum to the next in this regard:

Glad you got a solution that worked. If you're like me, you'll find a lot of help at tek-tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top