Datedif Function Excel For Mac 2016



Mac

LreAL wrote:

=DATEDIF(”04/06/1988”, NOW(), “Y”) & “ years, “ & DATEDIF(”04/06/1988”, NOW(), “YM”) & “ months, and “ & DATEDIF(”04/06/1988”, NOW(), “MD”) & “ days”

When looking for a syntax error, I often find it useful to break the formula down into its parts. To allow for different date formats (and different dates) with this one, I've also replaced the fixed date literal ('04/06/1988') with a cell reference, and placed the date in that cell.
=
DATEDIF(”04/06/1988”, NOW(), “Y”)
& “ years, “ &
DATEDIF(”04/06/1988”, NOW(), “YM”)
& “ months, and “ &
DATEDIF(”04/06/1988”, NOW(), “MD”)
& “ days”
That wasn't much help in this case, as each part of the formula looks correct.
So I decided to reconstruct the formula. I placed each DATEDIF statement into a separate cell on Row 2, placed the date in C2, and replaced the literal '04/06/1988' with a reference to C. All three parts worked flawlessly with either the literal or the reference to the cell in the same row of column C (which contained the date).
After removing all spaces that were not part of a literal text string (ie. that occurred outside pairs of quotation marks), I started adding the parts of the formula back on to the first part one line at a time, testing after each addition. The formula continued to work on each test, including a test of the final version below.
=DATEDIF(C, NOW(), 'Y')&' years, '&DATEDIF(C, NOW(), 'YM')&' months, and '&DATEDIF(C, NOW(), 'MD')&' days'
I also reinserted the spaces before and after the concatenation operator ( & ), and found their inclusion made no difference to the result.
So I don't know what was the syntax error, but did find that reconstructing the formula removed the error message and returned the correct result.
Regards,
Barry

May 24, 2010 11:39 PM

Function

Datedif Function Excel For Mac 2016 Manual

Jul 18, 2017 The DATEDIF function. Excel DATEDIF Function, Calculate Difference Between Two Dates In Excel, Tips and Tricks 2020 - Duration: 7:38. TheEngineeringWorld 1,667 views. Important note: the DATEDIF function returns the number of complete days, months or years. This may give unexpected results when the day/month number of the second date is lower than the day/month number of the first date. See the example below. The difference is 6 years. Almost 7 years! Use the following formula to return 7 years.

LreAL wrote:

=DATEDIF(”04/06/1988”, NOW(), “Y”) & “ years, “ & DATEDIF(”04/06/1988”, NOW(), “YM”) & “ months, and “ & DATEDIF(”04/06/1988”, NOW(), “MD”) & “ days”

When looking for a syntax error, I often find it useful to break the formula down into its parts. To allow for different date formats (and different dates) with this one, I've also replaced the fixed date literal ('04/06/1988') with a cell reference, and placed the date in that cell.
=
DATEDIF(”04/06/1988”, NOW(), “Y”)
& “ years, “ &
DATEDIF(”04/06/1988”, NOW(), “YM”)
& “ months, and “ &
DATEDIF(”04/06/1988”, NOW(), “MD”)
& “ days”
That wasn't much help in this case, as each part of the formula looks correct.
So I decided to reconstruct the formula. I placed each DATEDIF statement into a separate cell on Row 2, placed the date in C2, and replaced the literal '04/06/1988' with a reference to C. All three parts worked flawlessly with either the literal or the reference to the cell in the same row of column C (which contained the date).
After removing all spaces that were not part of a literal text string (ie. that occurred outside pairs of quotation marks), I started adding the parts of the formula back on to the first part one line at a time, testing after each addition. The formula continued to work on each test, including a test of the final version below.
=DATEDIF(C, NOW(), 'Y')&' years, '&DATEDIF(C, NOW(), 'YM')&' months, and '&DATEDIF(C, NOW(), 'MD')&' days'
I also reinserted the spaces before and after the concatenation operator ( & ), and found their inclusion made no difference to the result.
So I don't know what was the syntax error, but did find that reconstructing the formula removed the error message and returned the correct result.
Regards,
Barry

Microsoft Excel For Mac

May 24, 2010 11:39 PM