AHilberink Well-Known Member Licensed User Longtime User Aug 29, 2014 #1 Hi, Is there a simple way to calculate an age? Best regards, André
DonManfred Expert Licensed User Longtime User Aug 29, 2014 #2 Code: 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 Click to expand... Upvote 0
Code: 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 Click to expand...
DonManfred Expert Licensed User Longtime User Aug 29, 2014 #3 You can write it a bit shorter if you want... Code: Dim p As Period = DateUtils.PeriodBetween(DateTime.DateParse("12/19/1968"),DateTime.Now) Log(p.Years&" Years, "&p.Months&" months, "&p.Days&" days") Upvote 0
You can write it a bit shorter if you want... Code: Dim p As Period = DateUtils.PeriodBetween(DateTime.DateParse("12/19/1968"),DateTime.Now) Log(p.Years&" Years, "&p.Months&" months, "&p.Days&" days")
AHilberink Well-Known Member Licensed User Longtime User Aug 29, 2014 #4 DonManfred said: You can write it a bit shorter if you want... Code: Dim p As Period = DateUtils.PeriodBetween(DateTime.DateParse("12/19/1968"),DateTime.Now) Log(p.Years&" Years, "&p.Months&" months, "&p.Days&" days") Click to expand... Thanks. This will work for me. Upvote 0
DonManfred said: You can write it a bit shorter if you want... Code: Dim p As Period = DateUtils.PeriodBetween(DateTime.DateParse("12/19/1968"),DateTime.Now) Log(p.Years&" Years, "&p.Months&" months, "&p.Days&" days") Click to expand... Thanks. This will work for me.
DonManfred Expert Licensed User Longtime User Aug 29, 2014 #5 If you find a answer here in forum useful then please click on like. ;-) Upvote 0
AHilberink Well-Known Member Licensed User Longtime User Aug 29, 2014 #6 DonManfred said: If you find a answer here in forum useful then please click on like. ;-) Click to expand... Done Upvote 0
DonManfred said: If you find a answer here in forum useful then please click on like. ;-) Click to expand... Done
udg Expert Licensed User Longtime User Aug 30, 2014 #7 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
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
LucaMs Expert Licensed User Longtime User Feb 17, 2015 #9 udg said: 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 Click to expand... Not only women, I have always 5/10 years less, since I have over 40 years Upvote 0
udg said: 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 Click to expand... Not only women, I have always 5/10 years less, since I have over 40 years
DonManfred Expert Licensed User Longtime User Feb 18, 2015 #10 At a age of 30 is stopped counting... I´m 30! 30b, 30c, 30d, [...] I´m at P now Upvote 0
B bledfort New Member Jun 7, 2015 #11 DonManfred said: Code: 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") Click to expand... 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
DonManfred said: Code: 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") Click to expand... 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
DonManfred Expert Licensed User Longtime User Jun 7, 2015 #12 Code: Datestart = DateTime.DateParse(edittext1.text) Maybe you need to set the correct Dateformat before Upvote 0
Code: Datestart = DateTime.DateParse(edittext1.text) Maybe you need to set the correct Dateformat before