Datediff Behavior Warning
Understanding unexpected behavior.
VBA's DateDiff() function returns a Variant value representing a timed interval between two specific dates. For instance, the statement DateDiff("yyyy", #1/1/2000#, #1/1/2001#) would return the value 1, as there is one year between the two dates. But, there's an unexpected behavior you should know about. When trying to determine the years between December 31 of one year and January 1 of the next, Excel will return 1, even though there is only one day between the two dates. When you think it out, the result makes perfect sense because the dates are in two different years. However, at first, the function's response can be a bit disconcerting since the dates are only one day apart.
PCMag reviews products independently