Microsoft KB Archive/104808

From BetaArchive Wiki

MacWorks: Add/Subtract from a Given Time with TIME/MOD Functions

PSS ID Number: Q104808 Article last modified on 10-22-1998

3.0 4.0

MACINTOSH

======================================================================

The information in this article applies to:

  • == Microsoft Works for the Macintosh, version 3.0, 4.0 ==

SUMMARY

To add any number of hours, minutes, and/or seconds from a specific time of day, use the following formula:

=MOD(TIME(start-hour,start-minute,start-second) +TIME(hour-to-add,minute-to-add,second-to-add),1)

To subtract any number of hours, minutes, and/or seconds from a specific time of day, use the following formula:

=MOD(TIME(start-hour,start-minute,start-second) -TIME(hour-to-subtract,minute-to-subtract,second-to-subtract),1)

where:

hour is a number between 0 (midnight) and 23 (11:00 pm). minute is a number between 0 and 59. second is a number between 0 and 59.

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

=MOD(TIME(12,0,0)-TIME(25,10,0),1)

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. Because 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.

KBCategory: kbother KBSubcategory: mwksss mwksdb macworkskb

Additional reference words: 3.00 4.00 mac m_eXcel m_works

Version : 3.0 4.0 Platform : MACINTOSH Issue type : kbhowto ============================================================================= Copyright Microsoft Corporation 1998.