简体   繁体   中英

Error with DateDif in Excel

i am trying to use the DateDif function in Excel and this is an error and i had no idea why.

An example of the function that i want to calculate the number of years between the date is `

=DATEDIF("13/4/2013","1/1/2015","Y")

=DATEDIF("20/4/2013","1/1/2015","Y")

=DATEDIF("29/4/2013","1/1/2015","Y")

`Then the error came up was #VALUE! for all these above examples whereas if i use

=DATEDIF("12/4/2013","1/1/2015","Y")

=DATEDIF("5/4/2013","1/1/2015","Y")

There are no errors and the function worked correctly and the result is 1

Any help ? Or maybe its just a bug ?

=DATEDIF("12/4/2013","1/1/2015","Y")

Returns 1 because whether from December 4, 2013 or April 12, 2013 there is over a year and less than two years until January 1, 2015.

Similarly for your last example where whether May 4 or April 5 makes no difference.

Your first three examples return errors because your system is not interpreting 13/4/2013 , 20/4/2013 and 29/4/2013 as dates, as are required for DATEDIF . With your system set up you should see the results you were expecting from:

=DATEDIF("4/13/2013","1/1/2015","Y")  
=DATEDIF("4/20/2013","1/1/2015","Y")  
=DATEDIF("4/29/2013","1/1/2015","Y")

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