how many instances of "l" are there in:
q: formula for exact years (including decimal places) between two dates i'm using this formula to calculate a person's age:
if (
    month(today()) > month(birthdate),
    year(today()) - year(birthdate), 
    if (and(month(today()) = month(birthdate), day(today()) >= day(birthdate)),
        year(today()) - year(birthdate),
        (year(today()) - year(birthdate)) - 1
    )
)

which (i hope) correctly handles leap years.
i now need a formula to calculate the number of years between 2 dates that includes decimal places and accounts for leap years. dividing the difference between 2 dates by 365 (or 365.2422) only gives an approximate result (given that leap years happen in specific years).
is this possible using only a formula? if it is please share the formula...
or is updating via e.g. a trigger the more sane way to go?

a: a leap year is divisible by 400, or if it’s divisible by four but
not by 100. you'd need to use a variation on the 1st formula to also determine the number of leap years involved between the two dates. the formula for determining a leap year is as follows:
or(
mod( year( date ), 400 ) = 0,
and(
mod( year( date ), 4 ) = 0,
mod( year( date ), 100 ) != 0
)
)

once you found the 1st leap year following the birth date or the one that's prior to today(), you could easily calculate the number of leap years in-between the two dates.
knowing the above, it might be preferable to determine the number of days between the two dates.

a: this is the formula i have ended up using (where d1__c and d2__c are the two date fields):
round
(
    (year(d1__c) - year(d2__c))
    +
    (((d1__c - date(year(d1__c), 1, 1)) - (d2__c - date(year(d2__c), 1, 1))) / 365),
    2
)

its really based on the age formula from the original question plus this "day of the year" formula:
today() – date(year(today()), 1, 1) + 1

from handy salesforce formulas you can copy and paste. differencing the two "day of year" values and dividing by 365 provides the fractional part to add to the age formula. when the two formulas are put together the combination can then be simplified a bit.
using the year formula ensures that the non-fractional part isn't subject to leap year problems. arguably the fractional part divisor should be adjusted to be 365 or 366 or 367 but working to 2 decimal places and for the test cases i've tried (values below are d1__c, d2__c, expected years; all passing) the extra complexity does not appear necessary:
new testcase(date.newinstance(2016, 8, 29), date.newinstance(2016, 8, 29), 0.00),

new testcase(date.newinstance(2016, 8, 29), date.newinstance(2116, 8, 29), 100.00),
new testcase(date.newinstance(2016, 1, 20), date.newinstance(2021, 7, 20), 5.50),
new testcase(date.newinstance(2016, 11, 5), date.newinstance(2027, 2, 5), 10.25),
new testcase(date.newinstance(1964, 5, 25), date.newinstance(1989, 5, 9), 24.95),

new testcase(date.newinstance(2116, 8, 29), date.newinstance(2016, 8, 29), -100.00),
new testcase(date.newinstance(2021, 7, 20), date.newinstance(2016, 1, 20), -5.50),
new testcase(date.newinstance(2027, 2, 5), date.newinstance(2016, 11, 5), -10.25),
new testcase(date.newinstance(1989, 5, 9), date.newinstance(1964, 5, 25), -24.95)


user
In the text, there are 74 "l"s.
assistant