---
title: "DATEDIF practice: 3 exercises with answers | ExcelSavvy"
description: "Practice DATEDIF in Excel: work out an age, months of service, and years and months of service as text, in a live spreadsheet."
canonical_url: "https://excelsavvy.com/practice/datedif"
meta:
  "og:description": "Practice DATEDIF in Excel: work out an age, months of service, and years and months of service as text, in a live spreadsheet."
  "og:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_~REFURURJRiBwcmFjdGljZTogMyBleGVyY2lzZXMgd2l0aCBhbnN3ZXJz%2Cdescription_~UHJhY3RpY2UgREFURURJRiBpbiBFeGNlbDogd29yayBvdXQgYW4gYWdlLCBtb250aHMgb2Ygc2VydmljZSwgYW5kIHllYXJzIGFuZCBtb250aHMgb2Ygc2VydmljZSBhcyB0ZXh0LCBpbiBhIGxpdmUgc3ByZWFkc2hlZXQu%2Ceyebrow_Excel%2Bpractice%2Bexercises%2Csite_practiceexcel%2Cprops_eyJncmlkIjp7ImNvbHMiOlsiQSIsIkIiLCJDIl0sInJvd3MiOlt7Im4iOjEsImNlbGxzIjpbIkJvcm4iLCJEYXRlIiwiQWdlIl19LHsibiI6MiwiY2VsbHMiOlsiQXVnIDIwLCAxOTkwIiwiTWFyIDE1LCAyMDI0IiwiIl19XSwidGFyZ2V0IjpbMSwyXX19%2Cp_Ii9wcmFjdGljZS9kYXRlZGlmIg%2Cs_AhPzqzSvBvrYTFFh.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "DATEDIF practice: 3 exercises with answers | ExcelSavvy"
  "twitter:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_~REFURURJRiBwcmFjdGljZTogMyBleGVyY2lzZXMgd2l0aCBhbnN3ZXJz%2Cdescription_~UHJhY3RpY2UgREFURURJRiBpbiBFeGNlbDogd29yayBvdXQgYW4gYWdlLCBtb250aHMgb2Ygc2VydmljZSwgYW5kIHllYXJzIGFuZCBtb250aHMgb2Ygc2VydmljZSBhcyB0ZXh0LCBpbiBhIGxpdmUgc3ByZWFkc2hlZXQu%2Ceyebrow_Excel%2Bpractice%2Bexercises%2Csite_practiceexcel%2Cprops_eyJncmlkIjp7ImNvbHMiOlsiQSIsIkIiLCJDIl0sInJvd3MiOlt7Im4iOjEsImNlbGxzIjpbIkJvcm4iLCJEYXRlIiwiQWdlIl19LHsibiI6MiwiY2VsbHMiOlsiQXVnIDIwLCAxOTkwIiwiTWFyIDE1LCAyMDI0IiwiIl19XSwidGFyZ2V0IjpbMSwyXX19%2Cp_Ii9wcmFjdGljZS9kYXRlZGlmIg%2Cs_AhPzqzSvBvrYTFFh.png"
---

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

# **DATEDIF practice exercises**

Count the whole years or months between two dates, the way an age or years of service is counted.

[**Start the first exercise**](https://excelsavvy.com/practice/datedif/datedif-age)

DATEDIF(

## **How DATEDIF works**

DATEDIF counts the whole years, months or days between two dates. It takes three arguments: the start date, the end date and a unit in quotes. "y" gives whole years, "m" whole months and "d" days. It only counts complete periods, which is why it fits an age or years of service.

With a hire date of Mar 15, 2018 in A2 and Nov 20, 2024 in B2, `**=DATEDIF(A2,B2,"y")**` returns 6 and `**=DATEDIF(A2,B2,"m")**` returns 80. The unit "ym" gives the months left over after the whole years, here 8. Join the pieces with & to get text like 6 years, 8 months: `**=DATEDIF(A2,B2,"y")&" years, "&DATEDIF(A2,B2,"ym")&" months"**`.

The start date must come before the end date, or the formula returns #NUM!. Stay away from the unit "md": Microsoft warns that it can give wrong results. The exercises below cover an age in whole years, months of service and service as text with years and months.

1. [**1****Work out an age with DATEDIF**In C2, use DATEDIF with the unit "y" to work out the age in whole years on the date in B2 of someone born on A2.](https://excelsavvy.com/practice/datedif/datedif-age)
2. [**2****Months of service with DATEDIF****Premium**In C2, use DATEDIF to count the whole months of service from the hire date in A2 to the date in B2.](https://excelsavvy.com/practice/datedif/datedif-months-of-service)
3. [**3****Years and months of service as text****Premium**In C2, show the service from A2 to B2 as "6 years, 8 months". Join DATEDIF with "y" for the whole years, the text " years, ", DATEDIF with "ym" for the months left over and " months".](https://excelsavvy.com/practice/datedif/datedif-years-and-months)

## **Functions in this topic**

- [**DATEDIF**](https://excelsavvy.com/functions/datedif)

## **Read the guide**

- [**Dates in Excel: how they work and the formulas you need**](https://excelsavvy.com/learn/excel-dates)

## **Questions**

<details>

<summary>

### Why isn't DATEDIF in Excel's function list?

</summary>

DATEDIF is a legacy function that Excel keeps so older workbooks still work, so it does not show up in autocomplete or the Insert Function dialog. It works when you type the whole formula yourself, in current versions of Excel too. Just avoid the "md" unit, which can return wrong results.

</details>

<details>

<summary>

### How do I count the days between two dates in Excel?

</summary>

Subtract the earlier date from the later one: =B2-A2. If the result shows up as a date, change the cell format to General or Number. DATEDIF(A2,B2,"d") gives the same answer. To count only working days, use NETWORKDAYS instead.

</details>

<details>

<summary>

### How do I get the years between two dates with decimals?

</summary>

Use YEARFRAC: =YEARFRAC(A2,B2) returns the time between two dates as a fraction of a year, so 6 years and 8 months comes out near 6.7. Format the cell with two decimals if you want to see more. Use DATEDIF with "y" when you only want whole years.

</details>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://excelsavvy.com/#identity","@type":"Organization","name":"ExcelSavvy","url":"https://excelsavvy.com/","logo":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/#website","@type":"WebSite","inLanguage":"en-US","name":"ExcelSavvy","url":"https://excelsavvy.com/","alternateName":["Excel Savvy","ExcelSavvy.com","PracticeExcel","Practice Excel Online"],"publisher":{"@id":"https://excelsavvy.com/#identity"},"workTranslation":[{"@id":"https://excelopgaver.dk/#website"},{"@id":"https://excelpraxis.de/#website"}]},{"@id":"https://excelsavvy.com/practice/datedif#webpage","description":"Practice DATEDIF in Excel: work out an age, months of service, and years and months of service as text, in a live spreadsheet.","name":"DATEDIF practice: 3 exercises with answers","url":"https://excelsavvy.com/practice/datedif","@type":["WebPage","CollectionPage","FAQPage"],"breadcrumb":{"@id":"https://excelsavvy.com/practice/datedif#breadcrumb"},"isPartOf":{"@id":"https://excelsavvy.com/#website"},"mainEntity":[{"@id":"https://excelsavvy.com/practice/datedif#/schema/question/1"},{"@id":"https://excelsavvy.com/practice/datedif#/schema/question/2"},{"@id":"https://excelsavvy.com/practice/datedif#/schema/question/3"}],"potentialAction":[{"@type":"ReadAction","target":["https://excelsavvy.com/practice/datedif"]}],"primaryImageOfPage":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/practice/datedif#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://excelsavvy.com","position":1},{"@type":"ListItem","name":"Excel practice exercises","item":"https://excelsavvy.com/practice","position":2},{"@type":"ListItem","name":"DATEDIF practice: 3 exercises with answers","position":3}]},{"@id":"https://excelsavvy.com/practice/datedif#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"Why isn't DATEDIF in Excel's function list?","acceptedAnswer":{"@type":"Answer","text":"DATEDIF is a legacy function that Excel keeps so older workbooks still work, so it does not show up in autocomplete or the Insert Function dialog. It works when you type the whole formula yourself, in current versions of Excel too. Just avoid the \"md\" unit, which can return wrong results."}},{"@id":"https://excelsavvy.com/practice/datedif#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"How do I count the days between two dates in Excel?","acceptedAnswer":{"@type":"Answer","text":"Subtract the earlier date from the later one: =B2-A2. If the result shows up as a date, change the cell format to General or Number. DATEDIF(A2,B2,\"d\") gives the same answer. To count only working days, use NETWORKDAYS instead."}},{"@id":"https://excelsavvy.com/practice/datedif#/schema/question/3","@type":"Question","inLanguage":"en-US","name":"How do I get the years between two dates with decimals?","acceptedAnswer":{"@type":"Answer","text":"Use YEARFRAC: =YEARFRAC(A2,B2) returns the time between two dates as a fraction of a year, so 6 years and 8 months comes out near 6.7. Format the cell with two decimals if you want to see more. Use DATEDIF with \"y\" when you only want whole years."}},{"@id":"https://excelsavvy.com/#logo","@type":"ImageObject","caption":"ExcelSavvy","contentUrl":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3","inLanguage":"en-US","url":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3"}]}
```

## Sitemap

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