{"id":223,"date":"2026-10-01T02:02:44","date_gmt":"2026-10-01T02:02:44","guid":{"rendered":"https:\/\/thenesttools.com\/blog\/?p=223"},"modified":"2026-10-01T02:27:59","modified_gmt":"2026-10-01T02:27:59","slug":"excel-datedif-wrong-age","status":"publish","type":"post","link":"https:\/\/thenesttools.com\/blog\/excel-datedif-wrong-age\/","title":{"rendered":"Why Excel&#8217;s DATEDIF Gives the Wrong Age (and a Formula That Works)"},"content":{"rendered":"<p><strong>To calculate someone&#8217;s exact age in Excel, use <code>=DATEDIF(A2,TODAY(),\"Y\")<\/code> for years and <code>=DATEDIF(A2,TODAY(),\"YM\")<\/code> for months, but don&#8217;t use the &#8220;MD&#8221; unit for the leftover days.<\/strong> Microsoft&#8217;s own documentation warns that &#8220;MD&#8221; &#8220;may result in a negative number, a zero, or an inaccurate result&#8221;. A safer formula for the days is <code>=TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),\"M\"))<\/code>.<\/p>\n<p>Below: what each DATEDIF unit does, why &#8220;MD&#8221; goes wrong, a complete formula that gives years, months and days, and how to check your answer.<\/p>\n<h2>What DATEDIF Does<\/h2>\n<p>DATEDIF (&#8220;date difference&#8221;) counts the time between a start date and an end date in the unit you choose. It&#8217;s an old compatibility function that Excel still supports but doesn&#8217;t list in its function wizard, so you have to type it yourself. Google Sheets supports it too.<\/p>\n<table>\n<thead>\n<tr>\n<th>Unit<\/th>\n<th>What Microsoft says it returns<\/th>\n<th>Safe to use?<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&#8220;Y&#8221;<\/td>\n<td>The number of complete years in the period<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>&#8220;M&#8221;<\/td>\n<td>The number of complete months in the period<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>&#8220;D&#8221;<\/td>\n<td>The number of days in the period<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>&#8220;YM&#8221;<\/td>\n<td>The difference between the months, ignoring days and years<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>&#8220;YD&#8221;<\/td>\n<td>The difference between the days, ignoring years<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>&#8220;MD&#8221;<\/td>\n<td>The difference between the days, ignoring months and years<\/td>\n<td><strong>No: documented known issue<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If the start date is later than the end date, DATEDIF returns a <code>#NUM!<\/code> error, so the birth date always goes first.<\/p>\n<h2>Why the &#8220;MD&#8221; Unit Is a Problem<\/h2>\n<p>&#8220;MD&#8221; is meant to give the days left over after the last complete month, which is exactly the third number you need for an age like &#8220;36 years, 6 months, 10 days&#8221;. But months have different lengths, and &#8220;MD&#8221; works by ignoring the months entirely. Around month ends, especially when the birthday falls on the 29th, 30th or 31st, that shortcut can go wrong. Microsoft&#8217;s <a href=\"https:\/\/support.microsoft.com\/en-us\/excel\/functions\/datedif-function\" rel=\"noopener\" target=\"_blank\">DATEDIF support page<\/a> lists it under &#8220;Known issues&#8221;, and users regularly report odd results in <a href=\"https:\/\/techcommunity.microsoft.com\/t5\/excel\/datedif-s-known-issue-in-quot-md-quot-unit\/td-p\/126634\" rel=\"noopener\" target=\"_blank\">Microsoft&#8217;s community forums<\/a>.<\/p>\n<p>Microsoft&#8217;s suggested workaround subtracts the first day of the end month from the end date. That only gives the right answer when the start date is also the 1st of a month, so it doesn&#8217;t help for birthdays.<\/p>\n<h2>A Formula That Works: Years, Months and Days<\/h2>\n<p>With the date of birth in cell A2, use these three formulas:<\/p>\n<ul>\n<li><strong>Years:<\/strong> <code>=DATEDIF(A2,TODAY(),\"Y\")<\/code><\/li>\n<li><strong>Months:<\/strong> <code>=DATEDIF(A2,TODAY(),\"YM\")<\/code><\/li>\n<li><strong>Days:<\/strong> <code>=TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),\"M\"))<\/code><\/li>\n<\/ul>\n<p>The days formula works in two steps. <code>DATEDIF(A2,TODAY(),\"M\")<\/code> counts the complete months since birth. <code>EDATE<\/code> then adds that many months to the birth date, which gives the most recent &#8220;month-iversary&#8221;, and subtracting it from today leaves the extra days. Because EDATE handles month lengths properly, the result is never negative.<\/p>\n<p>To show everything in one cell:<\/p>\n<p><code>=DATEDIF(A2,TODAY(),\"Y\")&amp;\" years, \"&amp;DATEDIF(A2,TODAY(),\"YM\")&amp;\" months, \"&amp;TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),\"M\"))&amp;\" days\"<\/code><\/p>\n<p>To work out the age on a particular date instead of today, put that date in B2 and replace every <code>TODAY()<\/code> with <code>B2<\/code>.<\/p>\n<h2>Worked Example<\/h2>\n<p>Someone born on <strong>15 March 1990<\/strong>, measured on <strong>25 September 2026<\/strong>:<\/p>\n<ol>\n<li>Complete years: 36 (the 36th birthday was 15 March 2026).<\/li>\n<li>Complete months since then: 6 (15 March to 15 September 2026).<\/li>\n<li>Days since 15 September: 10.<\/li>\n<\/ol>\n<p>So the age is <strong>36 years, 6 months and 10 days<\/strong>. &#8220;M&#8221; returns 438 complete months, EDATE(15 March 1990, 438) is 15 September 2026, and 25 September minus 15 September is 10 days. The free <a href=\"https:\/\/thenesttools.com\/age-calculator\/\">age calculator<\/a> gives the same answer, which makes it a quick way to check a spreadsheet.<\/p>\n<h2>Birthdays on the 29th, 30th or 31st<\/h2>\n<p>When a birthday falls on a day that some months don&#8217;t have, there&#8217;s no single &#8220;right&#8221; answer, only conventions. EDATE counts one month after 31 January as the last day of February, so someone born on 31 January is 1 month and 1 day old on 1 March in a non-leap year. Our age calculator uses the same convention. Whatever method you use, apply it consistently across a spreadsheet, and check a few month-end birthdays by hand.<\/p>\n<h2>Common Mistakes<\/h2>\n<ul>\n<li><strong>Dates stored as text.<\/strong> If a date is left-aligned in the cell or was pasted from another system, Excel may treat it as text, and DATEDIF returns <code>#VALUE!<\/code>. Convert it with <code>=DATEVALUE(A2)<\/code> or re-enter it as a date.<\/li>\n<li><strong>Dates in the wrong order.<\/strong> The birth date must be the first argument, or you get <code>#NUM!<\/code>.<\/li>\n<li><strong>Using YEAR(TODAY())-YEAR(A2).<\/strong> This ignores whether the birthday has happened yet this year, so it&#8217;s a year too high for part of every year.<\/li>\n<li><strong>Dividing days by 365.<\/strong> <code>=(TODAY()-A2)\/365<\/code> drifts because of leap years. Use DATEDIF &#8220;Y&#8221; for whole years.<\/li>\n<\/ul>\n<h2>Frequently Asked Questions<\/h2>\n<h3>What is the formula to calculate age in Excel?<\/h3>\n<p>Use =DATEDIF(A2,TODAY(),&#8221;Y&#8221;) with the date of birth in A2. It returns the number of complete years, which is the age most people mean. Add &#8220;YM&#8221; for months, and use TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),&#8221;M&#8221;)) for the remaining days.<\/p>\n<h3>Why does DATEDIF give a negative number of days?<\/h3>\n<p>That&#8217;s the &#8220;MD&#8221; unit&#8217;s known issue. Microsoft documents that it can return a negative number, a zero or an inaccurate result. Replace it with TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),&#8221;M&#8221;)), which counts days from the last complete month.<\/p>\n<h3>Does DATEDIF work in Google Sheets?<\/h3>\n<p>Yes. Google Sheets supports DATEDIF with the same units, so the formulas above work there too. Test them on a few known dates before relying on them for a whole list.<\/p>\n<h3>Why can&#8217;t I find DATEDIF in Excel&#8217;s function list?<\/h3>\n<p>It&#8217;s a legacy compatibility function that Excel keeps for older workbooks but doesn&#8217;t show in autocomplete or the Insert Function dialog. Type it in full and it works normally.<\/p>\n<p><strong>Need an exact age without a spreadsheet? Enter a date of birth in the free <a href=\"https:\/\/thenesttools.com\/age-calculator\/\">age calculator<\/a> for years, months and days, or see total days lived with <a href=\"https:\/\/thenesttools.com\/age-calculators\/\">how many days old am I<\/a>.<\/strong><\/p>\n<p><em>Source: <a href=\"https:\/\/support.microsoft.com\/en-us\/excel\/functions\/datedif-function\" rel=\"noopener\" target=\"_blank\">Microsoft Support, DATEDIF function (known issues)<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel&#8217;s DATEDIF &#8220;MD&#8221; unit can return a wrong or negative number of days. Here&#8217;s the exact-age formula that works, with a worked example.<\/p>\n","protected":false},"author":1,"featured_media":259,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-223","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-date-time"],"_links":{"self":[{"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":1,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":260,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions\/260"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/media\/259"}],"wp:attachment":[{"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenesttools.com\/blog\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}