TimeSubtract

Subtracts one YmdHms variable from another.

Syntax:

TimeSubtract( datetime , datetime - difference)

Parameters:

(s) datetime  a datetime using the format of YYYY:MM:DD:HH:MM:SS.

(s) datetime difference a datetime to be subtracted from the original using the same format

Returns:

(s) a time string in YmdHms format.

 

Use this function to subtract a specified datetime from an original datetime. TimeSubtract uses normalized conversion so a valid datetime will be returned. "datetime difference" can not be larger than "datetime".

"datetime -difference" is an amount of time to be subtracted from datetime, in YmdHms format.

TimeSubtract is NOT designed to determine the difference between two points in time. For that, use TimeDiffDays, TimeDiffSecs, or the new TimeDiff function

IntControl 41 can be used to control YmdHms format returned by time functions.

Example:


; Subtract 1 day from 9/1/98 (at midnight)
newtime=TimeSubtract("1998:09:01:00:00:00", "0000:00:01:00:00:00")
Message("One day before 09/01/1998", newtime)
; Subtract 48 hours from the current time
newtime=TimeSubtract(TimeYmdHms(), "0000:00:00:48:00:00")
Message("Two days before today", newtime)
Message("TimeSubtract","Time Subtracted.")
See Also:

TimeAdd, TimeDiffDays, TimeDiffSecs, TimeDiff, IntControl 41