Microsoft KB Archive/95530

= How to Modify a Given Time Using TIME and MOD =

Article ID: 95530

Article Last Modified on 8/15/2005

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q95530




 * Microsoft Excel for Windows 2.0|2.0
 * Microsoft Excel for Windows 2.01|2.01
 * Microsoft Excel for Windows 2.1|2.1
 * Microsoft Excel for Windows 2.10c|2.10c
 * Microsoft Excel for Windows 2.10d|2.10d
 * Microsoft Excel for Windows 3.0|3.0
 * Microsoft Excel for Windows 3.0a|3.0a
 * Microsoft Excel for Windows 4.0|4.0
 * Microsoft Excel for Windows 4.0a|4.0a
 * Microsoft Excel for Windows 4.0c|4.0c
 * Microsoft Excel for Windows 5.0c|5.0c
 * Microsoft Excel for Windows NT 5.0|5.0
 * Microsoft Excel for the Macintosh 2.20|2.20
 * Microsoft Excel for the Macintosh 2.2a|2.2a
 * Microsoft Excel for the Macintosh 3.0|3.0
 * Microsoft Excel for the Macintosh 3.0a|3.0a
 * Microsoft Excel for the Macintosh 4.0|4.0
 * Microsoft Excel for the Macintosh 5.0|5.0
 * Microsoft Excel for the Macintosh 5.0a|5.0a





SUMMARY
In Microsoft Excel, time values are represented with serial numbers ranging from 0 (12:00:00 AM) to 0.999988426 (11:59:59 PM).

To subtract any number of hours, minutes, or seconds from a specific time of day, create a table similar to the following:

  A1:   Hours  B1:  A2: Minutes B2:  A3: Seconds B3:  A4:   Time  B4:  A5:   Less  B5: =TIME(B1,B2,B3) A6: Result  B6: =MOD(B4-B5,1)

NOTE: To add the time to a specific time of day, change the formula in cell B6 to:

  B6: =MOD(B4+B5,1)

For example, if you wanted to subtract 25 hours and 10 minutes from 12:00 PM, your table would look like the following example:

  A1: Hours    B1: 25 A2: Minutes B2: 10 A3: Seconds B3: 0 A4: Time    B4: 12:00 PM   A5: Less     B5: 1:10 A6: Result  B6: 10:50 AM

In this table:


 * Hours is the numbers of hours to subtract.
 * Minutes is the number of minutes to subtract.
 * Seconds is the number of seconds to subtract.
 * Time is the initial time that you are subtracting from.
 * Less is the total hours, minutes, and seconds being subtracted.
 * Result is the time value result of the formula.



MORE INFORMATION
This formula uses the TIME function to convert integer numbers to time values. If you want to add or subtract only hours, set the minutes and seconds arguments in the TIME function to 0 (zero).

The MOD function is used to ensure that the result is a positive time value. The MOD function returns the remainder after dividing the result by 1. Since the remainder is always the same sign as the divisor, and the possible remainders are from 0 to .99999999, this always produces a correct time value.

