---
title: "DATEDIF function in Excel: syntax and examples | PracticeExcel"
description: "How to use DATEDIF in Excel and Google Sheets: calculate an age, years of service or months between two dates."
canonical_url: "https://practiceexcelonline.com/functions/datedif"
locale: en
meta:
  "og:description": "How to use DATEDIF in Excel and Google Sheets: calculate an age, years of service or months between two dates."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~REFURURJRiBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBEQVRFRElGIGluIEV4Y2VsIGFuZCBHb29nbGUgU2hlZXRzOiBjYWxjdWxhdGUgYW4gYWdlLCB5ZWFycyBvZiBzZXJ2aWNlIG9yIG1vbnRocyBiZXR3ZWVuIHR3byBkYXRlcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~REFURURJRihzdGFydF9kYXRlLCBlbmRfZGF0ZSwgdW5pdCk%2Cp_Ii9mdW5jdGlvbnMvZGF0ZWRpZiI%2Cs_23qddMtf1YmMDoZh.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "DATEDIF function in Excel: syntax and examples | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~REFURURJRiBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBEQVRFRElGIGluIEV4Y2VsIGFuZCBHb29nbGUgU2hlZXRzOiBjYWxjdWxhdGUgYW4gYWdlLCB5ZWFycyBvZiBzZXJ2aWNlIG9yIG1vbnRocyBiZXR3ZWVuIHR3byBkYXRlcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~REFURURJRihzdGFydF9kYXRlLCBlbmRfZGF0ZSwgdW5pdCk%2Cp_Ii9mdW5jdGlvbnMvZGF0ZWRpZiI%2Cs_23qddMtf1YmMDoZh.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **The DATEDIF function**

Counts the whole years, months or days between two dates, which is how you work out an age or a length of service. Excel leaves it out of the function list, but it works.

=

DATEDIF(

## **Syntax**

```
DATEDIF(start_date, end_date, unit)
```

<dl><dt>**start_date **</dt>
<dd>The first date, such as a date of birth or a hire date.</dd>
<dt>**end_date **</dt>
<dd>The last date. It must not be before start_date, or the result is</dd>
<dt>**unit **</dt>
<dd>"Y" for whole years, "M" for whole months, "D" for days, "YM" for the months left over after whole years, "MD" for the days left over after whole months.</dd></dl>

## **Examples**

B1`=DATEDIF(<sup>1</sup>DATE(1990,6,15),<sup>2</sup>DATE(2024,3,15),<sup>3</sup>"Y")`

|  | A | B |
| --- | --- | --- |
| 1 |  | **33** |

**In plain words:** Count the <sup>3</sup>whole years from <sup>1</sup>Jun 15, 1990 to <sup>2</sup>Mar 15, 2024.

B1=DATEDIF(DATE(2024,1,31),DATE(2024,3,15),"M")

|  | A | B |
| --- | --- | --- |
| 1 |  | **1** |

B1=DATEDIF(DATE(2020,9,1),DATE(2024,3,15),"Y")&" years, "&DATEDIF(DATE(2020,9,1),DATE(2024,3,15),"YM")&" months"

|  | A | B |
| --- | --- | --- |
| 1 |  | **3 years, 6 months** |

## **Practice DATEDIF**

- [**1****Work out an age with DATEDIF**→](https://practiceexcelonline.com/practice/datedif/datedif-age)
- [**2****Months of service with DATEDIF**→](https://practiceexcelonline.com/practice/datedif/datedif-months-of-service)
- [**3****Years and months of service as text**→](https://practiceexcelonline.com/practice/datedif/datedif-years-and-months)

## **Questions**

<details>

<summary>

### How do I calculate someone's age in Excel?

</summary>

Use =DATEDIF(B2,TODAY(),"Y") with the date of birth in B2. It counts whole years, so the age goes up on the birthday itself.

</details>

<details>

<summary>

### Why can't I find DATEDIF in the list of functions?

</summary>

Excel keeps DATEDIF for compatibility with old Lotus 1-2-3 files and does not suggest it as you type. Type the whole name and it works in every version.

</details>

<details>

<summary>

### Why does DATEDIF return

</summary>

The start date is after the end date. Swap the two arguments.

</details>

## **Related functions**

- [**DATE**](https://practiceexcelonline.com/functions/date)
- [**TODAY**](https://practiceexcelonline.com/functions/today)
- [**YEAR**](https://practiceexcelonline.com/functions/year)
- [**DAYS**](https://practiceexcelonline.com/functions/days)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/functions/datedif#webpage","description":"How to use DATEDIF in Excel and Google Sheets: calculate an age, years of service or months between two dates.","name":"DATEDIF function in Excel: syntax and examples","url":"https://practiceexcelonline.com/functions/datedif","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://practiceexcelonline.com/functions/datedif#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"mainEntity":[{"@id":"https://practiceexcelonline.com/functions/datedif#/schema/question/1"},{"@id":"https://practiceexcelonline.com/functions/datedif#/schema/question/2"},{"@id":"https://practiceexcelonline.com/functions/datedif#/schema/question/3"}],"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/functions/datedif"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/functions/datedif#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://practiceexcelonline.com/functions","position":2},{"@type":"ListItem","name":"DATEDIF function in Excel: syntax and examples","position":3}]},{"@id":"https://practiceexcelonline.com/functions/datedif#article","description":"How to use DATEDIF in Excel and Google Sheets: calculate an age, years of service or months between two dates.","headline":"DATEDIF function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~REFURURJRiBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBEQVRFRElGIGluIEV4Y2VsIGFuZCBHb29nbGUgU2hlZXRzOiBjYWxjdWxhdGUgYW4gYWdlLCB5ZWFycyBvZiBzZXJ2aWNlIG9yIG1vbnRocyBiZXR3ZWVuIHR3byBkYXRlcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~REFURURJRihzdGFydF9kYXRlLCBlbmRfZGF0ZSwgdW5pdCk%2Cp_Ii9mdW5jdGlvbnMvZGF0ZWRpZiI%2Cs_23qddMtf1YmMDoZh.png","@type":["Article","TechArticle"],"author":{"@id":"https://practiceexcelonline.com/#identity"},"image":{"@id":"https://practiceexcelonline.com/#/schema/image/1"},"isPartOf":{"@id":"https://practiceexcelonline.com/functions/datedif#webpage"},"mainEntityOfPage":{"@id":"https://practiceexcelonline.com/functions/datedif#webpage"},"publisher":{"@id":"https://practiceexcelonline.com/#identity"}},{"@id":"https://practiceexcelonline.com/functions/datedif#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"How do I calculate someone's age in Excel?","acceptedAnswer":{"@type":"Answer","text":"Use =DATEDIF(B2,TODAY(),\"Y\") with the date of birth in B2. It counts whole years, so the age goes up on the birthday itself."}},{"@id":"https://practiceexcelonline.com/functions/datedif#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"Why can't I find DATEDIF in the list of functions?","acceptedAnswer":{"@type":"Answer","text":"Excel keeps DATEDIF for compatibility with old Lotus 1-2-3 files and does not suggest it as you type. Type the whole name and it works in every version."}},{"@id":"https://practiceexcelonline.com/functions/datedif#/schema/question/3","@type":"Question","inLanguage":"en-US","name":"Why does DATEDIF return","acceptedAnswer":{"@type":"Answer","text":"The start date is after the end date. Swap the two arguments."}},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"},{"@id":"https://practiceexcelonline.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~REFURURJRiBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBEQVRFRElGIGluIEV4Y2VsIGFuZCBHb29nbGUgU2hlZXRzOiBjYWxjdWxhdGUgYW4gYWdlLCB5ZWFycyBvZiBzZXJ2aWNlIG9yIG1vbnRocyBiZXR3ZWVuIHR3byBkYXRlcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~REFURURJRihzdGFydF9kYXRlLCBlbmRfZGF0ZSwgdW5pdCk%2Cp_Ii9mdW5jdGlvbnMvZGF0ZWRpZiI%2Cs_23qddMtf1YmMDoZh.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_~REFURURJRiBmdW5jdGlvbiBpbiBFeGNlbDogc3ludGF4IGFuZCBleGFtcGxlcw%2Cdescription_~SG93IHRvIHVzZSBEQVRFRElGIGluIEV4Y2VsIGFuZCBHb29nbGUgU2hlZXRzOiBjYWxjdWxhdGUgYW4gYWdlLCB5ZWFycyBvZiBzZXJ2aWNlIG9yIG1vbnRocyBiZXR3ZWVuIHR3byBkYXRlcy4%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~REFURURJRihzdGFydF9kYXRlLCBlbmRfZGF0ZSwgdW5pdCk%2Cp_Ii9mdW5jdGlvbnMvZGF0ZWRpZiI%2Cs_23qddMtf1YmMDoZh.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
