AMPscript Math Functions

The math functions below allow us to add, subtract, divide, and multiply numbers in Marketing Cloud Emails, Landing Pages, SMS/MMS Messages, and Push Notifications. You can write complex math equations to calculate numbers on the fly using these functions.

  • Add(N1,N2)
  • Subtract(N1, N2)
  • Multiply(N1, N2)
  • Divide(N1, N2)
  • Mod(N1, N2)

Add Function

The Add() function in AMPscript is used to add two numeric constants or two variables with a numeric value set.

Example
%%=Add(N1,N2)=%%


Subtract Function

The Subtract() function in AMPscript is used to subtract two numeric constants or two variables with a numeric value set.

Example
%%=Subtract(N1,N2)=%%


Multiply Function

The Multiply() function in AMPscript is used to multiply two numeric constants or two variables with a numeric value set.

Example
%%=Multiply(N1,N2)=%%


Divide Function

The Divide() function in AMPscript is used to divide two numeric constants or two variables with a numeric value set.

Example
%%=Divide(N1,N2)=%%


Mod Function

The Mod() function in AMPscript is used to find the remainder between two numeric constants or two variables with a numeric value set.

Example
%%=Mod(N1,N2)=%%


Gallery