<script runat="server" language="ampscript">
    SET @x = 100
    SET @y = 5

    SET @output1 = @x * @y  // Why this does NOT work!

    SET @output2 = Multiply(@x,@y)   //And only this works!!

    Output = %%=v(@output1)=%% <br/>        //Output = 100 
    Output = %%=v(@output2)=%%              //Output = 500

1 Answer 1


As shown in the documentation (and more clearly stated in the AMPscript Guide), all math can only be done via the functions listed in the syntax guide [MULTIPLY(), SUBTRACT(), ADD(), etc.] unlike other languages that can use the operators of [-,+,*,/].

In contrast to many other scripting languages that use operators like +, -,*, and \, AMPscript uses a set of functions for addition, subtraction, multiplication and division. AMPscript also includes specific math functions for performing modulo operations and generating random numbers.

  • AMPscript Guide

In AMPscript these operators are ignored and in fact can potentially cause errors or incorrect output.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .