Sie sind auf Seite 1von 9

How to use dates and times in Excel Page 1

Article ID: 214094 - Last Review: February 1, 2007 - Revision: 6.8


How to use dates and times in Excel
This article was previously published under Q214094 For a Microsoft Excel 2001 for Mac version of this article, see 303216 (http://support.microsoft.com/
kb/303216/ ) .

For Microsoft Office Excel 2007, visit the Office Online Excel 2007 Help and How-to Web page (http://office.microsoft.com/en-us/excel/FX100646951033.aspx?
CTT=96"&"Origin=CL100570551033) .

This step-by-step article describes how to use the built-in date and time functions in Microsoft Excel to perform complex date
and time calculations.

Excel stores all dates as integers and all times as decimal fractions. With this system, Excel can add, subtract, or compare dates and times just like any other
numbers, and all dates are manipulated by using this system.

In this system, the serial number 1 represents 1/1/1900 12:00:00 a.m. Times are stored as decimal numbers between .0 and .99999, where .0 is 00:00:00
and .99999 is 23:59:59. The date integers and time decimal fractions can be combined to create numbers that have a decimal and an integer portion. For
example, the number 32331.06 represents the date and time 7/7/1988 1:26:24 a.m.

To help you perform complex date and time calculations, Excel includes many built-in date and time functions.

The TODAY() Function and the NOW() Function


The TODAY function returns the serial number of today's date based on your system clock and does not include the time. The NOW function returns the serial
number of today's date and includes the time.

How Dates Are Sorted Based on Serial Number


In Excel, dates are sorted based on the serial number of the date, instead of on the displayed number. Therefore, when you sort dates in Excel, you may not
receive the results you expect.

For example, if you sort a series of dates that are displayed in the mmmm date format (so that only the month is displayed), the months are not sorted
alphabetically. Instead, the dates are sorted based on their underlying date serial number.

How Dates Are Compared Based on Serial Number


Because serial numbers are also used in date and time comparisons, actual results may be different than what you expect (based on the displayed values).

For example, when you use the NOW function to compare a date with the current date, as in the formula

the formula returns FALSE, even if the current date is 10/1/92; it returns TRUE only when the date is 10/1/92 12:00:00 a.m. If you are comparing two dates in a
formula, and you do not have to have the time included in the result, you can work around this behavior by using the TODAY function instead:

How to Work with Date Formulas

How to Find the Number of Days Between Today and a Future Date
To find the number of days between now and a date sometime in the future, use the following formula

where "mm/dd/yy" is the future date. Use the General format to format the cell that contains the formula.

How to Find the Number of Days, Months, and Years Between Two Dates
To calculate the number of days, months, and years between two dates, where the start and end dates are entered in cells A1 and A2 respectively, follow these
steps:

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 2

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 3

If you type the formula correctly, cell D1 displays:

Additional Formula Breakdown for Days, Months, and Years

This formula can also be broken down into individual segments of days, months, and years as follows.

Note If you copy and paste these formulas, make sure that there are no line breaks or the formulas will not work.

Note In the earlier formulas, &" days", &" months", and &" years" are optional. These allow you to distinguish the results as days, months, and years.

How to Find the Number of Weekdays Between Two Dates


To find the number of weekdays between two dates, where the start and end dates are typed in cells A1 and A2 respectively, follow these steps:

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 4

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 5

Note If you see #NAME as the result, click Add-Ins on the Tools menu. Click to select the Analysis ToolPak check box, and then click Yes if you are
prompted as to whether you want to install it.

How to Increase Dates Incrementally


To increase a date by a number of years, months, or days, use the following formula, where reference is either the date value or cell reference that contains the
date, and value1, value2, and value3 are the increments by which you want to increase the year, month, and day, respectively.

For example, to increase a date by one month, the formula is:

How to Work with Time Formulas

How to Calculate Elapsed Time


When you subtract the contents of one cell from another to find the amount of time elapsed between them, the result is a serial number that represents the
elapsed hours, minutes, and seconds. To make this number easier to read, use the h:mm time format in the cell that contains the result.

In the following example, if cells C2 and D2 contain the formula =B2-A2, and cell C2 is formatted in the General format, the cell displays a decimal number (in
this case, 0.53125, the serial number representation of 12 hours and 45 minutes).

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 6

If midnight falls between your start time and end time, you must account for the 24-hour time difference. You can do this by adding the number 1, which
represents one 24-hour period. For example, you might set up the following table, which allows for time spans beyond midnight.

To set up this table, type the following formula in cells C2 and D2:

How to Accumulate Hours and Minutes Greater Than 24 Hours


If you want to correctly display a time greater than 24 hours, you can use the 37:30:55 built-in format. If you want to use a custom format instead, you must
enclose the hours parameter of the format in brackets, for example:

How to Convert a Date to Its Decimal Number Equivalent


To convert a serialized date (h:mm:ss) to a decimal number (0.00), you must convert the serial number to a decimal by converting to a 24-hour base. You do
this by multiplying the time by 24 as follows

where Time is the number that you want to convert from a time format to a decimal number; this number can be a cell reference or a string of numbers in the
TIMEVALUE function.

For example, if cell A1 contains a time of "4:30" to represent four hours and 30 minutes, the formula is:

The result is 4.5.

If the cell contains both a date and a time, use the following formula:

For example, if cell A1 reads "6/20/96 4:30 AM", the formula is:

The result again is 4.5.

How to Convert a Decimal Number to Its Date Equivalent


To convert a decimal number (0.00) to its serial date equivalent (h:mm:ss), you must convert the serial number to a decimal by converting to a 24-hour base.
You do this by dividing the time by 24 as follows

where Time is the number that you want to convert from a decimal number to a date serial number and can be a cell reference or a real number. For example, if
you have a value of 4.5 to represent four hours and 30 minutes in cell A1, the formula is:

The result is 4:30.

How to Transfer Files Between Microsoft Excel for Mac and Excel for Windows
By default, Excel for Mac uses the 1904 date system and Excel for Windows uses the 1900 date system. This means that when you type the serial number 1 in
Excel for Mac and format it as a date, Excel displays it as 1/2/1904 12:00 a.m. Excel for Windows displays the serial number 1 as 1/1/1900 12:00 a.m.

If you transfer files from Excel for Mac to Excel for Windows, this difference in the date systems should not cause a problem, because the date system is stored in
each file. However, if you copy and paste between files with different date systems that originated on different platforms, dates may be displayed four years and
one day away from their correct date.

To change to the 1904 date system in Excel for Windows, follow these steps:

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 7

To change to the 1904 date system in Excel for Mac, follow these steps:

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 8

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base: 214233
(http://support.microsoft.com/kb/214233/ ) Text or number converted to unintended number format in Excel 214386 (http://support.microsoft.com/
kb/214386/ ) Maximum times in Microsoft Excel 241072 (http://support.microsoft.com/kb/241072/ ) Dates and times displayed as serial numbers when
viewing formulas in Excel 264372 (http://support.microsoft.com/kb/264372/ ) How to control and understand settings in the Format Cells dialog box in
Excel

APPLIES TO

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10


How to use dates and times in Excel Page 9

Keywords: kbnomt kbgraphxlink kbscreenshot kbdatetime kbautomation kbprogramming kbfunctions kbhowtomaster kbmigrate KB214094

Get Help Now


Contact a support professional by E-mail, Online, or Phone

Microsoft Support

http://support.microsoft.com/kb/214094 14.05.2010 01:31:10

Das könnte Ihnen auch gefallen