How can I create a function which gives me the exact age based on the given birthdate until today? I created the following function, but the function returns me the wrong the Age. For example: if I provide dateOfBirth := 08/15/1990 and try to calculate date as of today’s date it will return 30 instead of 29. Can someone plz help me with this?
Age = math.Floor(Today.Now().Sub(*dateOfBirth).Hours() / 24 / 365)
The 15th day of August 1990 was the date of birth, today os the 10th day of September 2020.
Aus September is following August, and the difference of 2020 - 1990 is 30, 30 seems indeed to be the correct result. Not sure why you expect 29.
Beyond that, a day has not always 24 hours. It can have 23 or 25 as well (DST) or even 24h+/-1 second (leap seconds). Also a year is not 365 days, it is 365.23ish days. Thats why we have an extra day in february every 4 years (skipping each 25th, but not skipping the 4th skip)…