Great! Actually, the other way it is likely to be wrong is when
today's date is very close to the persons birthday - eg if a persons
age is really 16 yrs 11 months, and their birthday is a couple of
days from now, it may give 17 yrs 0 months.
These date/period things can be tricky, so you have to decide how
accurate you need to be, and do the extra work to accomodate that!
Best,
Mark
On 8 Sep 2006, at 14:16, William de Smet wrote:
Thanks Mark,
It works!
Like I said it's an educational stack so the pupils/students are not
older than 20 so leap years are not important.
greetings,
William de Smet
2006/9/8, Mark Smith <[EMAIL PROTECTED]>:
function getAge bDay
put 60 * 60 * 24 * 365 into secsPerYear
put secsPerYear / 12 into secsPerMonth
put the seconds into tDay
-- assuming date of birth is given in short system date format
convert bDay from short system date to seconds
put tDay - bDay into tAgeInSecs
put tAgeInSecs div secsPerYear into tYears
put (tAgeInSecs mod secsPerYear) div secsPerMonth into tMonths
return tYears && tMonths
end getAge
This is pretty rough and ready, it doesn't try to take into account
leap years and so-on, but unless the person is really old (100 yrs
+ ?), it should be close enough. Also, see 'centuryCutoff' in the
docs if you're going to be dealing with older people.
Best,
Mark
On 8 Sep 2006, at 13:22, William de Smet wrote:
> Hi there,
>
> For an educational app I want to calculate someone's age based
on date
> of birth and todays date but I don't know how to start!
> I made a field in which the user puts its 'date of birth' (dd/mm/
yy)
> and a button that needs to compare 'todays date' and the 'date of
> birth'.
>
> The output needs to be : age and months (and days?)
>
> Is there someone who has any suggestions?
>
> greetings,
>
> William de Smet
> _______________________________________________
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
ICT-coördinator
Herman Broerenschool
2612 SP Delft
015-2141066
http://www.hermanbroerenschool-delft.nl
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution