What is fast way to figure out how old a persons?[/quote]
This ones more tricky depending how precise you want to be
You could subtract birth year from current & get a “yer 10” even though their birthday hasnt yet passed
My mom gets this as she was born dec 30 so folks always overstate her age by a year
Note that this may not actually be days as calculated on a calendar due to daylight savings time changes, leap years, or leap seconds. The new Xojo.Core.Date class lets you subtract two dates to get a Xojo.Core.DateInterval object back.
For example, with the new Xojo.Core.Date class you can use this code to determine how old someone is:
Using Xojo.Core
Dim birthDay As New Date(2000, 6, 14, TimeZone.Current)
Dim elapsed As DateInterval
elapsed = Date.Now - birthDay
Dim years As Integer = elapsed.Years // 14 years
Dim months As Integer = elapsed.Months // 6 months
Dim days As Integer = elapsed.Days // 3 days
Exactly - the OLD date had no built in way to account for the many of the vagaries that dates & times have.
The new one does so handles this much better.
One of those little things that until you have to do it and see how hard it is to do right you dont appreciate
I spent ages writing and testing a little piece of code to calc the years, months and days between two dates.
It worked but didn’t factor in leap years.
Now I can just use this!
Nice.
[quote=153317:@Norman Palardy]Exactly - the OLD date had no built in way to account for the many of the vagaries that dates & times have.
The new one does so handles this much better.
One of those little things that until you have to do it and see how hard it is to do right you dont appreciate[/quote]