Information générale
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Network:
Windows 2000 Server
Sorry late to chime in, but there was also another shortcut is by using DTOS() which also works for leap years too.... 2004 was the last leap year so the formula is age = (VAL(DTOS(DATE())) - VAL( DTOS( ? ))) / 10000
birthdate = CTOD( "2/29/2004")
compareto = CTOD( "3/1/2005")
? (VAL( DTOS( compareto )) - VAL( DTOS( birthdate ))) / 10000
result is 1 yr
compareto = CTOD( "2/28/2005")
? (VAL( DTOS( compareto )) - VAL( DTOS( birthdate ))) / 10000
result is .9999 yr old
Jump to next leap year
compareto = CTOD( "2/29/2008")
? (VAL( DTOS( compareto )) - VAL( DTOS( birthdate ))) / 10000
result is 4.0
>We need totals of clients by age bracket. What is the best way to calculate the age? Right now, we are using:
>
>INT((DATE() - a.dob) / 365)
>
>But that doesn't take into consideration leap years (which could be significant for someone over 90 years old). Any suggestions? Should I just use:
>
>INT((DATE() - a.dob) / 365.25)
>
>Or is there a better (more accurate) way?
>
>Thanks,
>Doug
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement