By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,631 Members | 826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,631 IT Pros & Developers. It's quick & easy.

yy date format gives a result with 4 digits

P: 10
i have a query that subtracts the date of birth (dob) from the date, i.e.
age_d: Date()-[dob]
This is OK as it gives me the difference in days e.g. 700 days. i would like the result to show me the age as Years/Months. If i use yy/mm as the format, the result gives a full year format and month e.g 1903/04. for sure this is not what i want, i would like a format e.g. 03/04.

Anyone please assist.
Apr 17 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 10K+
P: 14,534
Try this ...

age_d: CStr(DateDiff("m", [dob], Date())/12) & " " & CStr(DateDiff("m", [dob], Date())%12)
Apr 20 '07 #2

P: 10
Thanks but i found another much longer solution i.e. i have a column that returns a value depending on the date of birth and the current birth;

dt_variance: (DatePart("d",Date())<DatePart("d",[Dob]))

After i use this value to get the number of months;

Months: Int(DateDiff("m",[dob],Date()))+[dt_variance]

Then i het the number of years and months & combine both values;

AgeYears: Int([Months]/12)
AgeMonths: [Months] Mod 12

Thanks for your post though i never tried the solution. My solution works though very long process.
Oct 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.