# EnvAdd

Sets a variable to the sum of itself plus the given value (can also add or subtract time from a date-time value). Synonymous with: `var += value`.

    EnvAdd, Var, Value , TimeUnits
    Var += Value , TimeUnits
    Var++

## Parameters

Var

  The name of the variable upon which to operate.

Value

  Any integer, floating point number, or expression.

TimeUnits

  If present, this parameter directs the command to add Value to Var, treating Var as a date-time stamp in the YYYYMMDDHH24MISS format and treating Value as the integer or floating point number of units to add (specify a negative number to perform subtraction). TimeUnits can be either Seconds, Minutes, Hours, or Days (or just the first letter of each of these).

  If Var is an empty variable, the current time will be used in its place. If Var contains an invalid timestamp or a year prior to 1601, or if Value is non-numeric, Var will be made blank to indicate the problem.

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

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

## Remarks

This command is equivalent to the shorthand style: `Var += Value`.

Variables can be increased or decreased by 1 by using `Var++`, `Var--`, `++Var`, or `--Var`.

If either Var or Value is blank or does not start with a number, it is considered to be 0 for the purpose of the calculation (except when used internally in an expression and except when using the TimeUnits parameter).

If either Var or Value contains a decimal point, the end result will be a floating point number in the format set by SetFormat.

## Related

EnvSub, EnvMult, EnvDiv, SetFormat, Expressions, If var is [not] type, SetEnv, FileGetTime

## Examples

#1

    EnvAdd, MyCount, 2
    MyCount += 2  ; Equivalent to above

#2: Date math.

    var1 := ""  ; Make it blank so that the below will use the current time instead.
    var1 += 31, days
    MsgBox, %var1%  ; The answer will be the date 31 days from now.