# Thread: Age in years and months

1. Registered User
Join Date
Jun 2002
Posts
72

## Unanswered: Age in years and months

I have 2 dates (eg 01/01/2000 and 06/06/2002) and by subtracting the first date from the second date require the answer in years and months only (eg 2 years and 6 months). Does anyone know of a good way to do this.

Thanks

2. Registered User
Join Date
Apr 2002
Location
Germany
Posts
228
a bit odd, but should do the trick

dim totalmonths as integer
dim months as integer
dim years as integer

'time difference in months
totalmonths=datediff("m",#01/01/2000#,#06/06/2002#)
'that makes in whole years
years=totalmonths / 12
'and the remaining months
months=totalmonths mod 12

note: this will result in 2 years and 5 months as it's not full 6 months (the 6th month has started but it's not yet finished).

3. Registered User
Join Date
Jun 2002
Posts
72
Thanks

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•