If you want to work with Excel dates and times, it is useful to understand the way that Excel stores dates and times.
Dates and times are actually stored as simple numbers within Excel. It is only the Formatting of a spreadsheet's cells, that causes a number to be displayed as a date, time, or date & time.
Within Excel, dates and times are coded as follows:
Dates  Dates in Excel are stored as positive integers. For example, on most computer systems:
Therefore, when entered into a spreadsheet, the integer values, 1, 2 and 40209 are displayed as follows (depending on the cell formatting):
 
Times  Times in Excel are stored as decimals, between 0 and 1, which represent a proportion of the day. For example:
Therefore, when entered into a spreadsheet, the decimal values, 0, 0.25 and 0.5 are displayed as follows (depending on the cell formatting):
 
Dates & Times  Date & Time values in Excel are stored as decimals, comprised of:
For example, on most computer systems:
Therefore, when entered into a spreadsheet, the above values are displayed as follows (depending on the cell formatting):

Because Excel stores dates & times as numbers you can add, subtract and compare dates and times in Excel in the same way that you would add or subtract any other numbers.
Examples are provided below:
A  B  

1  20/08/2010  =A2A1 
2  31/08/2010 
Cell B1 of the above spreadsheet on the right uses the formula =A2A1 to calculate the number of days between the dates 20/08/2010 & 31/08/2010 (stored in cells A1 and A2).
This gives the result 11.A  B  

1  13:00  =A2A1 
2  17:15 
Cell B1 of the above spreadsheet on the right uses the formula =A2A1 to calculate the number of hours and minutes between the times 13:00 & 17:15 (stored in cells A1 and A2).
This gives the result 04:15.
(Note that, in order to display this result, cell B1 should be formatted to have the time format "hh:mm").
A  B  

1  30/08/2010 17:00  =A2A1 
2  31/08/2010 09:00 
Cell B1 of the above spreadsheet on the right uses the formula =A2A1 to calculate the number of hours and minutes between the two dates & times stored in cells A1 and A2.
This gives the result 16:00.
(Note that, in order to display this result, cell B1 should be formatted to have the time format "hh:mm").
A  B  

1  30/08/2010 17:00  =A1+A2 
2  23:00 
Cell B1 of the above spreadsheet on the right uses the formula =A1+A2 to calculate the date and time that is 23 hours after the date & time 30/08/2010 17:00.
This gives the result 31/08/2010 16:00.
(Note that, in order to display this result, cell B1 should be formatted to have the date and time format "dd/mm/yyyy hh:mm").
The results in of the above Excel date and time formulas may not have the required formatting when first input into your spreadsheet. This may give the initial impression that the formula has not worked  however, this is not the case.
The cells can be made to show the correct result by formatting into a 'General', 'Date', 'Time', or 'Date & Time' format, depending on the required result type.
The easiest way to change the formatting of one or more Excel cells is to select the cell(s) to be formatted and then select the required formatting type from the dropdown menu in the ribbon. This is generally found in the 'Number' group on the Home tab (see below):
If you don't see the formatting style that you require, select the option More Number Formats ... from the dropdown format menu. This opens up the 'Format Cells' dialog box, which provides several additional preprogrammed formats or allows you to define your own Custom format.