DateAdd

Adds or subtracts time from a date-time value.

Result := DateAdd(DateTime, Time, TimeUnits)

Parameters

DateTime

Type: String

A date-time stamp in the YYYYMMDDHH24MISS format.

Time

Type: Integer or Float

The amount of time to add, as an integer or floating-point number. Specify a negative number to perform subtraction.

TimeUnits

Type: String

The meaning of the Time parameter. TimeUnits may be one of the following strings (or just the first letter): Seconds, Minutes, Hours or Days.

Return Value

Type: String

This function returns a string of digits in the YYYYMMDDHH24MISS format. This string should not be treated as a number (one should not perform math on it or compare it numerically).

Remarks

The built-in variable A_Now contains the current local time in YYYYMMDDHH24MISS format.

To calculate the amount of time between two timestamps, use DateDiff.

If DateTime contains an invalid timestamp or a year prior to 1601, an exception is thrown.

Related

DateDiff, FileGetTime, FormatTime

Examples

#1: Calculate the date 31 days from now.

later := DateAdd(A_Now, 31, "days")
MsgBox FormatTime(later)