18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Part II<br />

Working with Formulas and Functions<br />

Converting from military time<br />

Military time is expressed as a four-digit number from 0000 to 2359. For example, 1:00 AM is expressed as<br />

0100 hours, and 3:30 PM is expressed as 1530 hours. The following formula converts such a number<br />

(assumed to be in cell A1) to a standard time:<br />

=TIMEVALUE(LEFT(A1,2)&”:”&RIGHT(A1,2))<br />

The formula returns an incorrect result if the contents of cell A1 do not contain four digits. The following<br />

formula corrects the problem, and it returns a valid time for any military time value from 0 to 2359:<br />

=TIMEVALUE(LEFT(TEXT(A1,”0000”),2)&”:”&RIGHT(A1,2))<br />

Following is a simpler formula that uses the TEXT function to return a formatted string, and then it uses the<br />

TIMEVALUE function to express the result in terms of a time.<br />

=TIMEVALUE(TEXT(A1,”00\:00”))<br />

Converting decimal hours, minutes, or seconds to a time<br />

To convert decimal hours to a time, divide the decimal hours by 24. For example, if cell A1 contains 9.25<br />

(representing hours), this formula returns 09:15:00 (nine hours, 15 minutes):<br />

=A1/24<br />

To convert decimal minutes to a time, divide the decimal hours by 1,440 (the number of minutes in a day).<br />

For example, if cell A1 contains 500 (representing minutes), the following formula returns 08:20:00 (eight<br />

hours, 20 minutes):<br />

=A1/1440<br />

To convert decimal seconds to a time, divide the decimal hours by 86,400 (the number of seconds in a<br />

day). For example, if cell A1 contains 65,000 (representing seconds), the following formula returns<br />

18:03:20 (18 hours, three minutes, and 20 seconds):<br />

=A1/86400<br />

Adding hours, minutes, or seconds to a time<br />

You can use the TIME function to add any number of hours, minutes, or seconds to a time. For example,<br />

assume that cell A1 contains a time. The following formula adds 2 hours and 30 minutes to that time and<br />

displays the result:<br />

=A1+TIME(2,30,0)<br />

You can use the TIME function to fill a range of cells with incremental times. Figure 13.9 shows a worksheet<br />

with a series of times in 10-minute increments. Cell A1 contains a time that was entered directly. Cell<br />

A2 contains the following formula, which copied down the column:<br />

=A1+TIME(0,10,0)<br />

246

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!