Question Locked

Help on an Excel formula

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need some help on an Excel formula..

I need to calculate a formula to count the exact number of days between two dates.

For Example:

Cell A1 contains 01/01/2007
Cell A2 contains 31/01/2007
Cell A3 needs to contain the answer (31)
All the formula's i can think of return the answer (30).

I would very much appreciate your help on this one.

3 replies

by travler92

To calculate the difference in days, use the DATEDIF function as shown in the following formula:
=DATEDIF(A2,B2,"d")

To calculate the difference in weeks, use the INT function as shown in the following formula:
=INT((B2-A2)/7)

To calculate the difference in months, use the DATEDIF function as shown in the following formula:
=DATEDIF(A2,B2,"m")

To calculate the difference in years, use one of the following two solutions:
Use the DATEDIF function as shown in the following formula:
=DATEDIF(A2,B2,"y")

OR

Use the YEAR, MONTH, AND, and DAY functions as shown in the following formula:

=YEAR(B2)-YEAR(A2)-(MONTH(B2) To calculate the number of months over years, use the DATEDIF function as shown in the following formula:
=DATEDIF(A2,B2,"ym")

To calculate the number of days over years, use the DATEDIF function as shown in the following formula:
=DATEDIF(A2,B2,"yd")

by bizzo

DATEDIF(A1,A2,"d") will return the number of days between dates, in your example, 30, this is correct, because if A1=A2, the number of days between days will be zero. You require the answer to this to be 1 (or 31 in your example).

Simply add 1 to the function.
=DATEDIF(A1,A2,"d")+1

This discussion is closed to new replies.