简体   繁体   中英

How to Calculate DATEDIF formula in Excel?

I would like to get the CalculatedValue for the formula =DATEDIF("5/7/2018","6/6/2018","m") .In Excel it returns zero.

I would like to know what process used while calculating the above formula.

Can anyone please let me know the actual process behind getting the month between two dates ?

Use:

=DATEDIF(DATEVALUE("5/7/2018"),DATEVALUE("6/6/2018"),"m")

will return 0

在此处输入图片说明

However:

=DATEDIF(DATEVALUE("5/7/2018"),DATEVALUE("6/7/2018"),"m")

will return 1

"5/7/2018" is May 7th, but there is not a full month until June 6th, hence the zero result.
DATEDIF(start_date,end_date,"M") gives the number of complete months in the period.

Please also note that dates in Excel can be tricky, as it depends on your regional settings.
"5/7/2018" could be July 5th (in my region), hence after June 6th, which should give a #NUM error if you use the DATEDIF function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM