SalesforceLabs / AnimalShelterStarter

Animal Shelter Starter provides the foundation to use Salesforce for managing animals, treatments, conditions, housing and related activities.
16 stars 10 forks source link

Date Calculation Error #76

Closed GeekStewie closed 2 years ago

GeekStewie commented 2 years ago

Calculated Age is wonky with some dates. I checked the formula and I can see why (365 day years and 30 day months not always the case) but I also know age cals are a nightmare to get right, as it depends on how an organisation defines their month and day calcs (could vary). Maybe a decimal years-only value would be easier to deal with?

Test data if you need it: DOB = 10th August 2021 shows 1 YEARS 0 MONTHS 0 DAYS DOB = 11th August 2021 shows 0 YEARS 12 MONTHS 4 DAYS …same pattern for a few days, reducing day count… DOB = 15th August 2021 shows 0 YEARS 12 MONTHS 0 DAYS DOB = 16th August 2021 shows 0 YEARS 11 MONTHS 29 DAYS

cjrolfe commented 2 years ago

Could try the following to account for Leap Years

IF(ISBLANK(Date_of_Birth__c), Estimated_Agec, FLOOR((TODAY()-Date_of_Birthc +1)/365.2425))