[AccessD] Age Calculation - Yeah, I'm going there again!

Ralf Lister rlister at actuarial-files.com
Thu May 19 18:48:45 CDT 2011


Hello John,

I have this code snippet, may be it helps:

Function AgeInMonths(End As Date, Begin As Date) As Integer
'************************************************************
'************************************************************
'** Name of Procedure: AgeInMonths
**
'** Date: January 2011
**
'** Called from: various in modReservas, modReservasInv
**
'** Calls: none
**
'** Task: Calculates the age of a person in month
**
'** Input: End, Begin (Both Date)
**
'** Output: Integer
**
'** Example: AgeInMonths(#30/4/2011#,#25/11/2009#) = 17                   **
'************************************************************
'************************************************************
    
Dim xM As Integer

If Day(End) < Day(Begin) Then
    xM = (Year(End) - Year(Begin)) * 12 + _
            Month(End) - Month(Begin) - 1
Else
    xM = (Year(End) - Year(Begin)) * 12 + _
            Month(End) - Month(Begin)
End If

AgeInMonths = xM
            
End Function

Saludos
Actuary Ralf Lister
La Paz, Bolivia
Registrado en ASFI
No. Registro: Act.Mat. 001
NIT: 1016725022
Skype Name: ralf.martin.lister
Tel.: 222 26 61, Cel. 70136531
rlister at actuarial-files.com
www.actuarial-files.com



-----Mensaje original-----
De: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] En nombre de John Clark
Enviado el: Jueves, 19 de Mayo de 2011 11:58 a.m.
Para: 'Access Developers discussion and problem solving'
Asunto: [AccessD] Age Calculation - Yeah, I'm going there again!

I've got this quickie program I whipped up, that our health department wants
to use, for entering and tracking surveyed data regarding children and
dental visits. There are 3 separate surveys depending on the childs age, and
this can change as the child ages. 
 
I've pretty much got the whole thing done, but...one of their age groups is
"6 Months to 4 Yrs of Age." This really doesn't matter to me, because it is
irrelevant in the program...I check for "under 4 yrs" for this group. But,
they want the yrs and months to show for age. And, of course, my only code
just give age in years. 
 
Anyone have code that does age in yrs and months?
 
Thanks ahead of time!
 
J Clark
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1375 / Virus Database: 1509/3647 - Release Date: 05/19/11




More information about the AccessD mailing list