Try Microsoft Edge
A fast and secure browser that's designed for Windows 10
I created a Calculated field using Diffindays to calculate Age based on Today and dob field.
'DiffInDays(cat_dateofbirth, Now()) / 365'
The issue I have it does not take into consideration leap years. Is there anything I could add to the formula to make this work?
Or any code that does the job?
//Get 1 day in milliseconds
//Calculate difference btw the two dates, and convert to days
var todayDays = Math.ceil((today.getTime()-millennium.getTime())/(one_day));
See following article for more info, but there are plenty more:
In C# it's much easier:
int totalDays = EndDate.Date.Subtract(DateTime.Now.Date).Days;
int totalDays = DateTime.Now.Subtract(EndDate.Date).Days;
Hope this helps.
why don't you use DiffinYears instead of DiffinDays?
Or are you trying to get a decimal number for the age (as in 10.5, 40.73)?
If that's the case, you might probably try:
DiffinYears(cat_dateofbirth, NOW()) +DiffinDays(ADDYEARS(cat_dateofbirth, DiffinYears(cat_dateofbirth, NOW())), NOW()) / 365
In other words, first get diff in years.. then add the portion of the year which is left after that
There could still be a bit of difference, but it'would only be there if the last year was a leap year
Agreed doesn’t look like it is possible with OOB functionality.
Business Applications communities