Android Question Calculating Age

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 :D
 
Upvote 0

bledfort

New Member
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")
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
Top