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

Year <= the current year ? 3

Status
Not open for further replies.

Rmcta

Technical User
Joined
Nov 1, 2002
Messages
478
Location
US
I have tblYear with 1 column (1996, 1997, 1998..etc)
I need to create a query to retrieve all the years that are <= the current year.

How do I do it?[ponder]

[pc2]Thank you
 
SELECT *
FROM tblYear
WHERE tblYear.YearNum <= Year(Date());
 
GREAT!
Thank you very much [thumbsup2]
 
I am now trying to find out how old my population is but my query is not working.

Can anyone help me fix it:

SELECT Name, date()-(CDate([tblContacts].[DOB_Month] & &quot;/&quot; & [tblContacts].[DOB_Day] & &quot;/&quot; & [tblContacts].[DOB_Year])) as Age
from tblContacts;

[pc2]Thank you
 
[tt]select Name
, year(date()) - DOB_year
- iif(month(date()) > DOB_month,0,
iif(month(date()) < DOB_month,1,
iif(day(date()) < DOB_day,1,0))) as Age
from tblContacts[/tt]

however, i would not store three fields like that, i would store one date field for DOB

this means you would have to pull out the year, month, day in the above query using YEAR(), MONTH() and DAY() functions, but that's better than always re-constructing a date from the individual fields when you want the entire DOB


rudy
 
Thank you very much to you all.
Rama
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top