Calculating the number of days between two dates in Excel

I consider 7 days to be a week, so if I look at 1 January 2019 - 7 January 2019, I would say that is 7 days.  But often I seen when people are calculating the number of days between two dates or age they use the formula B1-A1 where A1 is the Start Date/DoB and B1 is the end date or today's date.  This would give 6 for the above example.

I use (B1-A1)+1 which gives 7 and for dates of birth I would use ((B1-A1)+1)/365.25.  Which is correct?

5

3 Answers

It is not a question of one formula being right and the other being wrong. It is a question of what you are looking for.

Say you are working on a task 24 hours a day. You begin the task 17 January 2000 at 9:00 AM and complete the task 18 January 2000 at 9:00 AM. If the question is How many days did the task take ? You would take the difference; get 24 hours and answer 1 day.

If, however, the question is On how many days did you work on the task ? You would immediately respond 2

Thus =B1 - A1 or =B1 - A1 + 1 might be appropriate depending on what you are trying to measure.

The answer revolves around how Excel deals with dates. When days between dates are calculated using formulae such as B1-A1, Excel would turn the dates into serial numbers and use the serial numbers to calculate the number or days in between.

By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900. (Source: Microsoft)

So the days between January 1, 1900 and January 7, 1900 would equal 7 minus 1 equalling 6.

The same would apply with 1/1/2008 - 7/1/2008

January 1, 2008 is 39,447 and
January 7, 2008 is 39,453

39,453 — 39,447 = 6

If you wish to count the days inclusive you would need to add 1 to make the formula to be for example B1-A1+1.

If you want to calculate days exclusive you would need to minus 1 day making B1-A1-1

1

I wold like to suggest 3 different Formula to Calculate AGE between 2 Dates.

enter image description here

  1. To get only Years:

=INT((B1-A1)/365)

Or,

=ROUNDDOWN(YEARFRAC(A1, B1, 1), 0)

Or, you may use TODAY() Function also:

=ROUNDDOWN(YEARFRAC(A1, TODAY(), 1), 0)

  1. To Get Complete Age in Years, Months and Days use this one.

    =DATEDIF(A1,B1,"Y") & " Years, " & DATEDIF(A1,B1,"YM") & " Months, " & DATEDIF(A1,B1,"MD") & " Days"

Edited:

Counting number of days between two Dates is little bit arbitrary. Basically depends on need.

  1. Count number of days, Excluding Start Date.
  2. Count number of days, Including Start Date.
  3. Count number of days, Excluding both Start & End Date.

enter image description here

Considering OP's Sample Dates following Formula can be used.

Formula for situation 1:

=DATEDIF(B2,B3,"d")

=DAYS(B3,B2)

=INT(B3-B2)

Formula for situation 2:

=DATEDIF(B2,B3,"d")+1

=DAYS(B3,B2)+1

=INT(B3-B2+1)

Formula for situation 3:

=DATEDIF(B2,B3,"d")-1

=DAYS(B3,B2)-1

=INT(B3-B2-1)

Adjust Cell references in the Formula as needed.

7

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like