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.
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 dateThe 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!