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

Query results for age under 1 year? 1

Status
Not open for further replies.

lucybelle

MIS
Apr 9, 2001
58
US
I'm using MS Access 97. This is the formula that I'm using in a query to calculate the age of a client:

ClientAge:Int(DateDiff("m",[tblgloclients]![ClientDOB],
Date())/12)

If the age is under 1 year, I get 0. How can I get the number of months when this is the case? Thanks.
 
Brute force method:
ClientAge:IIf(Date()-[tblgloclients]![ClientDOB]>365, Int(DateDiff("m",[tblgloclients]![ClientDOB],Date())/12), DateDiff("m",[tblgloclients]![ClientDOB],Date()))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That worked great! Thanks! [2thumbsup] How can I get it to show "months" when the age is less than 1?
 
That worked great! [2thumbsup] How can I get it to show "months" when the age is less than 1?
 
That worked great! How can I get it to show "months" when the age is less than 1?
 
ClientAge:IIf(Date()-[tblgloclients]![ClientDOB]>365, Int(DateDiff("m",[tblgloclients]![ClientDOB],Date())/12) & " Year(s)", DateDiff("m",[tblgloclients]![ClientDOB],Date()) & " Month(s)")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Works Perfect!!!!! Thanks for your help.
[Smile2][Smile2][Smile2][Smile2][Smile2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top