## Days between two dates

The DATEDIF function in cell E3 allows you to calculate days between two dates.

The function is hidden in the formula bar and the arguments are not shown surprisingly. The first argument is the start date, the second is the end date. The third is the unit.

There seems to be an issue with days between two dates if you use date and time as an argument.

The DATEDIF function should return complete days, however, in this case, it rounds the number up to the nearest whole number. The picture above shows you this issue in cell E4.

A much easier formula is to simply subtract the earlier date from the later date. Excel dates are actually numbers between 1 and 99999 formatted as dates, this allows you to do mathematical operations to dates.

You can see that yourself by selecting a cell containing a date and then press CTRL + 1. This opens a dialog box where you can see how the cell is formatted.

Press with mouse on General to show the number. 1/1/2017 is in fact 42736. Number 1 is 1/1/1900.

If you use dates and time and want to calculate the number of days and hours between two dates use the following formula:

The result is displayed in cell F5 on the picture above.

INT(C5-B5)& " days "

The INT function removes the decimal part from the number returning complete days. The & (ampersand) concatenates the number with the text string " days".

HOUR(B5-C5-INT(B5-C5))&" hours"

The HOUR function returns a number representing the hour. The decimal part of the number is the time, in this case, hours.

To get the decimal part simply subtract the integer part from the number, this is where the INT function comes in.

Lastly, the ampersand & character concatenates the hour number with " hours".

You can get even greater detail by using the MINUTE and SECOND functions as well.

### Get Excel *.xlsx

Identify overlapping date ranges

The formula in cell F6 returns TRUE if the date range on the same row overlaps another date range in […]

Find date range based on a date

This article demonstrates a formula that returns a date range that a date falls under, cell C3 above contains the […]

The DATE function returns a number that acts as a date in the Excel environment. The image above shows you […]

How to use the DATEDIF function

The DATEDIF function returns the number of days, months, or years between two dates. The DATEDIF function exists in order to […]

Question: I am trying to create an excel spreadsheet that has a date range. Example: Cell A1 1/4/2009-1/10/2009 Cell B1 […]

Find latest date based on a condition

This article demonstrates how to return the latest date based on a condition using formulas or a Pivot Table. The […]

Formula for matching a date within a date range

This article demonstrates how to match a specified date to date ranges. The image above shows a formula in cell […]

How to calculate overlapping time ranges

I found an old post that I think is interesting to write about today. Think of two overlapping ranges, it […]

Column C contains both date and time, to calculate the average of only time we need to extract the hours, minutes […]

Returns an integer representing the hour of an Excel time value. The returning number is ranging from 0 (12:00 A.M.) […]

This workbook contains two worksheets, one worksheet shows a calendar and the other worksheet is used to store events. The […]

The calendar shown in the image above highlights events based on frequency. It is made only with a few conditional […]

Removes the decimal part from positive numbers and returns the whole number (integer) except negative values are rounded down to […]

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form