11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6: Working with Dates and Times 175<br />

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

following formula corrects the problem and returns a valid time for any military time value from<br />

0 to 2359:<br />

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

The following is a simpler formula that uses the TEXT function to return a formatted string and<br />

then uses the 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<br />

9.25 (representing hours), this formula returns 09:15:00 (9 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<br />

in a day). For example, if cell A1 contains 500 (representing minutes), the following formula<br />

returns 08:20:00 (8 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<br />

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

returns 18:03:20 (18 hours, 3 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<br />

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

to that time and displays the result:<br />

=A1+TIME(2,30,0)

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

Saved successfully!

Ooh no, something went wrong!