Android Question Calculating Age

AHilberink

Well-Known Member
Licensed User
Longtime User
Hi,

Is there a simple way to calculate an age?

Best regards,
André
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Dim Datestart As Long
    Datestart = DateTime.DateParse("12/19/1968")
    Dim p As Period
    p = DateUtils.PeriodBetween(Datestart,DateTime.Now)
    Log(p.Years&" Years, "&p.Months&" months, "&p.Days&" days")
45 Years, 8 months, 10 days
 
Upvote 0

udg

Expert
Licensed User
Longtime User
ATTN: to be "safe" on calculating women age the above formula should be changed to:

Dim p As Period = DateUtils.PeriodBetween(DateTime.DateParse("12/19/1968"),DateTime.Add(DateTime.Now,-10,0,0))

Sorry, I couldn't resist
 
Upvote 0

bledfort

New Member
Hi, How can I make Datestart related to an entry from an EditText, something like this I mean:
Datestart = DateTime.DateParse(EditText1.text)

thanks in advance
 
Upvote 0

Similar Threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…