Page 285 - Excel 2007 Bible
P. 285

18_044039 ch13.qxp  11/21/06  11:05 AM  Page 242
                                   Part II
                                              Working with Formulas and Functions
                                             Displaying the current time
                                             This formula displays the current time as a time serial number (or as a serial number without an associated
                                             date):
                                                  =NOW()-TODAY()
                                             You need to format the cell with a time format to view the result as a recognizable time. The quickest way is
                                             to choose Home ➪ Number ➪ Format Number and select Time from the drop-down list.
                                                       This formula is updated only when the worksheet is calculated.
                                          NOTE
                                           NOTE
                                                       To enter a time stamp (that doesn’t change) into a cell, press Ctrl+Shift+: (colon).
                                            TIP
                                            TIP
                                             Displaying any time
                                             One way to enter a time value into a cell is to just type it, making sure that you include at least one colon
                                             (:). You can also create a time by using the TIME function. For example, the following formula returns a
                                             time comprised of the hour in cell A1, the minute in cell B1, and the second in cell C1:
                                                  =TIME(A1,B1,C1)
                                             Like the DATE function, the TIME function accepts invalid arguments and adjusts the result accordingly.
                                             For example, the following formula uses 80 as the minute argument and returns 10:20:15 AM. The 80 min-
                                             utes are simply added to the hour, with 20 minutes remaining.
                                                  =TIME(9,80,15)
                                        CAUTION        If you enter a value greater than 24 as the first argument for the TIME function, the result may
                                        CAUTION
                                                       not be what you expect. Logically, a formula such as the one that follows should produce a
                                             date/time serial number of 1.041667 (that is, one day and one hour).
                                               =TIME(25,0,0)
                                             In fact, this formula is equivalent to the following:
                                               =TIME(1,0,0)
                                             You can also use the DATE function along with the TIME function in a single cell. The formula that follows
                                             generates a date and time with a serial number of 39420.7708333333 — which represents 6:30 PM on
                                             December 4, 2007:
                                                  =DATE(2007,12,4)+TIME(18,30,0)
                                             The TIMEVALUE function converts a text string that looks like a time into a time serial number. This for-
                                             mula returns 0.2395833333, the time serial number for 5:45 AM:
                                                  =TIMEVALUE(“5:45 am”)
                                             To view the result of this formula as a time, you need to apply number formatting to the cell. The
                                             TIMEVALUE function doesn’t recognize all common time formats. For example, the following formula
                                             returns an error because Excel doesn’t like the periods in “a.m.”
                                                  =TIMEVALUE(“5:45 a.m.”)
                                      242
   280   281   282   283   284   285   286   287   288   289   290