DATEDIF function

Calculates the number of days, months, or years between two dates.

Warning: Excel provides the DATEDIF function in order to support older workbooks from Lotus 1-2-3. The DATEDIF function may calculate incorrect results under certain scenarios. Please see the known issues section of this article for further details.

## Syntax

DATEDIF(start_date,end_date,unit)

Argument

Description

start_date

Required

A date that represents the first, or starting date of a given period. Dates may be entered as text strings within quotation marks (for example, "2001/1/30"), as serial numbers (for example, 36921, which represents January 30, 2001, if you're using the 1900 date system), or as the results of other formulas or functions (for example, DATEVALUE("2001/1/30")).

end_date

Required

A date that represents the last, or ending, date of the period.

Unit

The type of information that you want returned, where:

 Unit Returns "Y" The number of complete years in the period. "M" The number of complete months in the period. "D" The number of days in the period. "MD" The difference between the days in start_date and end_date. The months and years of the dates are ignored. Important: We don't recommend using the "MD" argument, as there are known limitations with it. See the known issues section below. "YM" The difference between the months in start_date and end_date. The days and years of the dates are ignored "YD" The difference between the days of start_date and end_date. The years of the dates are ignored.

## Remarks

• Dates are stored as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.

• The DATEDIF function is useful in formulas where you need to calculate an age.

• I﻿f the start_date is greater than the end_date, the result will be #NUM!.

## Examples

 Start_date End_date Formula Description (Result) 1/1/2001 1/1/2003 =DATEDIF(Start_date,End_date,"Y") Two complete years in the period (2) 6/1/2001 8/15/2002 =DATEDIF(Start_date,End_date,"D") 440 days between June 1, 2001, and August 15, 2002 (440) 6/1/2001 8/15/2002 =DATEDIF(Start_date,End_date,"YD") 75 days between June 1 and August 15, ignoring the years of the dates (75)

## Known issues

The "MD" argument may result in a negative number, a zero, or an inaccurate result. If you are trying to calculate the remaining days after the last completed month, here is a workaround: This formula subtracts the first day of the ending month (5/1/2016) from the original end date in cell E17 (5/6/2016). Here's how it does this: First the DATE function creates the date, 5/1/2016. It creates it using the year in cell E17, and the month in cell E17. Then the 1 represents the first day of that month. The result for the DATE function is 5/1/2016. Then, we subtract that from the original end date in cell E17, which is 5/6/2016. 5/6/2016 minus 5/1/2016 is 5 days.

## Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8568047,"math_prob":0.8869084,"size":2557,"snap":"2021-43-2021-49","text_gpt3_token_len":708,"char_repetition_ratio":0.11633372,"word_repetition_ratio":0.033254158,"special_character_ratio":0.3066093,"punctuation_ratio":0.12941177,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9732373,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-11-30T21:09:08Z\",\"WARC-Record-ID\":\"<urn:uuid:591c3b3f-f461-4682-82d7-343e8e2fe69e>\",\"Content-Length\":\"120057\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c0e24ae3-673c-410d-a2fe-c98697f21cac>\",\"WARC-Concurrent-To\":\"<urn:uuid:3dacf58b-c74a-42de-9042-6d3cba42c528>\",\"WARC-IP-Address\":\"23.62.164.116\",\"WARC-Target-URI\":\"https://support.microsoft.com/en-us/office/datedif-function-25dba1a4-2812-480b-84dd-8b32a451b35c?omkt=en-us&ui=en-us&rs=en-us&ad=us\",\"WARC-Payload-Digest\":\"sha1:I6FXDIOSA4JUSMTKQHXXVFQDYBQUKWRG\",\"WARC-Block-Digest\":\"sha1:CX6TB3JTFPOL5OKX25HMDAXIGW5SLTV7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964359073.63_warc_CC-MAIN-20211130201935-20211130231935-00330.warc.gz\"}"}