Selasa, 03 April 2012

Re: [MS_AccessPros] Re: Return Count of Records based on Age in Query

 

Age Function works as you shown me but I need to just count the records where the applicant is 55 years or older.
 
I tried this but it did not work.
 
SELECT Count(tblApplicant.ApplicantID) AS CountOfApplicantID, CalcAge([DOB]) AS Age
FROM tblApplicant
HAVING (((CalcAge([DOB]))>=55));

With warm regards,

Arthur Lorenzini
Sioux Falls, South Dakota

________________________________
From: Bill Mosca <wrmosca@comcast.net>
To: MS_Access_Professionals@yahoogroups.com
Sent: Tuesday, April 3, 2012 3:25 PM
Subject: [MS_AccessPros] Re: Return Count of Records based on Age in Query


 

Art -
All you need is a Age function.

Public Function CalcAge(DOB As Variant)
'Purpose : Calculate age
'DateTime : 3/18/2000 10:50
'Author : Bill Mosca
On Error Resume Next

CalcAge = DateDiff("yyyy", DOB, Now()) _
+ Int(Format(Now(), "mmdd") < Format(DOB, "mmdd"))

End Function

Then use it in your query like this:
SELECT FirstName, LastName, DOB, CalcAge([DOB]) as Age
FROM MyTable

--- In MS_Access_Professionals@yahoogroups.com, "Art" <dbalorenzini@...> wrote:
>
> I need to get a count of records for all applicants 55 years of age or older.
>
> Fields
>
> ApplicantID
> DOB
>
> Please advise
>
> Thank you
>
> Art Lorenzini
> Aioux Falls.
>

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar