years between dates

Viewing 5 reply threads
  • Author
    Posts
  • January 22, 2023 at 7:59 PM #48779

    Glen Forister
    Participant

    What is wrong with this to find the difference in years between two dates?

    (MONTHS(Today;Purchased))/12

    I’ve also tried = MONTHS(Today;Purchased)/12
    All I get is = Dec 31, 1969 at 3:59:54 PM

    The field for the # of years is decimal style with 2 decimal places.

    January 23, 2023 at 9:55 PM #48781

    Brendan
    Keymaster

    Hi Glen,

    Did you try the YEARS(TODAY(); Purchased) function instead?

    That’ll give you the number of years between those two dates.

    Also TODAY() is a function, so you need the ().

    January 24, 2023 at 11:39 AM #48784

    Glen Forister
    Participant

    That wasn’t on the list to select from.
    Tried it and get a date as result. = Dec 31, 1969 at 3:59:50 PM

    field is calculated
    type is Decimal

    Is there another setting someplace?

    Attachments:
    You must be logged in to view attached files.
    January 24, 2023 at 3:10 PM #48786

    Brendan
    Keymaster

    It was in the list of functions on the right on the Formula Edit screen.

    In any case, you have your Result Type set to return a Date value, but the YEARS() function actually returns a Number type.

    January 24, 2023 at 3:29 PM #48787

    Glen Forister
    Participant

    Thanks. That setting gets me every time.

    But, why is the result look at a quick glance, but why are all the values negative? ie: -4.

    My numbers for age in months is positive, but these are all negative.

    AH, position matters. I got it…
    Thanks.

    January 24, 2023 at 6:25 PM #48789

    Brendan
    Keymaster

    You could also add ABS() around your function to get the absolute value, which will always return a positive number.

    ABS(X) returns the absolute value. e.g. ABS(4) = 4 and ABS(-4) = 4.

Viewing 5 reply threads

You must be logged in to reply to this topic.