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

Query Expression Question

Status
Not open for further replies.

Bill6868

Technical User
Mar 20, 2007
96
US
In a query I have an expression that calculates a person's age based on today's date and their DOB. Is it possible to create another expression that calculates all these people's ages and gives me an average. Could I do this at the query level or do I have to do it at the report design level? I'm not clear on how do do this at either level.

Thanks for your help.
 
Show your query where you "have an expression that calculates a person's age based on today's date and their DOB" and I am sure somebody will modify it to give you an average age.


---- Andy

There is a great need for a sarcasm font.
 
Thanks Andy. Here's the expression: Age: (Now()-[DOB])/365.2425
 
Could you show the entire query?
It is easier to add the Average column to your existing statement, if that's the approach you want to take.

Otherwise, something like:[tt]
SELECT ..., Now()-[DOB])/365.2425 As Age,[blue]
Avg([/blue]Now()-[DOB])/365.2425[blue]) As AvgAge[/blue]
From ...
GROUP By ...[/tt]

Where in [tt]Group By[/tt] you mention all fields from your [tt]Select[/tt] statement except AvgAge


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top