Calculate age age calculator
Code:
DOB := "02/15/1998" ; input the birthdate (the format is MM/DD/YYYY)
StringSplit, dates, DOB, `/ ; chops up DOB
MAct:= A_MM ; setting variable for current month
AAct:= A_YYYY ; setting variable for current year
DAct:= A_DD ; setting variable for current day
MNac:= dates1 ; setting variable for birth month
ANac:= dates3 ; setting variable for birth year
DNac:= dates2 ; setting variable for birth day
sleep, 10 ; chilling for a sec
If (MAct<MNac)
{
Age:=AAct-ANac-1
}
If (MAct=MNac and DAct<DNac)
{
Age:=AAct-ANac-1
}
If (MAct=MNac and DAct>=DNac)
{
Age:=AAct-ANac
}
If (MAct>MNac)
{
Age:=AAct-ANac
}
sleep, 100 ; chilling for a sec
MsgBox, The age is %age%
A little while ago I needed a way to calculate age off of knowing a birthdate. Most documentation I found wasn't really working in my case, so after working through what was best for me, I wanted to turn around and share it to hopefully help someone else down the road. Probably not the most elegant way of doing things and it could be reduced somewhat but I think it is stable and pretty easy to understand
Re: Calculate age age calculator
If you’re looking to calculate age with AutoHotkey, I'd check out skyth540’s script for simplicity. For a web-dependent option, TheDewd shared an interesting alternative that pulls data online.
Re: Calculate age age calculator
Your script for calculating age sounds useful. I've had success using an online tool that accurately provides an exact chronological age by simply entering a birthdate. The tool accounts for leap years and can even project future ages. It's been handy when I needed quick results without coding. Maybe give it a try to see how it complements your scripting approach.