Home  >  Article  >  Topics  >  What is the function of datedif?

What is the function of datedif?

藏色散人
藏色散人Original
2019-06-04 09:20:414623browse

The DATEDIF function is a hidden function in Excel and is not available in the help or insert formulas. Returns the number of years\months\days between two dates. The DATEDIF function is often used to calculate the difference between two dates. Contains D,M,Y,YD,YM,MD.

What is the function of datedif?

Syntax

DATEDIF(start_date,end_date,unit)

Start_date is a date, which represents the first date or starting date in the time period. (The start date must be after 1900)

End_date is a date, which represents the last date or end date within the time period.

Unit is the return type of the required information.

Unit Returns

Note: The end date must be greater than the start date

Here is a small example: very practical in daily work .

If cell A1 also writes a date, then the following three formulas can calculate the difference between the date in cell A1 and today's time, which are the difference in years, months, and days respectively. Note that the quotation marks and comma brackets in the formula below are all entered in English mode.

=DATEDIF(A1,TODAY(),"Y") calculates the difference in years

=DATEDIF(A1,TODAY(),"M") calculates the difference in months

=DATEDIF(A1,TODAY(),"D") Calculate the number of days difference

"Y" The number of whole years in the time period.

"M" The number of whole months in the time period.

"D" The number of days in the time period.

"MD" The number of days between the start date and the end date in the same month. Ignore the month and year in the date.

"YD" The number of days between the start date and the end date in the same year. Ignore the year in the date.

"YM" The number of months between the start date and the end date in the same year. Ignore year

in date

The above is the detailed content of What is the function of datedif?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn