2 Replies Latest reply: Jul 20, 2016 12:54 PM by rodrigo silva

# Setting variable returns incorrect results?

Adding the following to my script in Sense 2.4

LET vYearPreviousX2 = Year(YearStart(Today())-2);                 //Returns (2015)

LET vMonthPreviousX2 =  Month(MonthStart(Today())-2);        // Returns (Jun)

Returns the same results as:

LET vYearPrevious = Year(YearStart(Today())-1);                    // Returns (2015)

LET vMonthPrevious = Month(MonthStart(Today())-1);            // Returns (Jun)

Anything jump out at you?

• ###### Re: Setting variable returns incorrect results?

You are subtracting 1 or 2 days from your YearStart, which will only take you 2015. May be you need theses

LET vYearPreviousX2 = Year(AddYears(Today(), -2));                 //Should give you 2014

LET vYearPrevious = Year(AddYears(Today(), -1));                     //Should give you 2015

LET vMonthPreviousX2 =  Month(AddMonths(Today(), -2));        //Should give you May

LET vMonthPrevious = Month(AddMonths(Today(), -1));        //Should give you Jun

• ###### Re: Setting variable returns incorrect results?

Yur result it´s the same because you subtracts 1 and 2 day of yearstart of today.

if you whant substract 1 or 2 year or months use the expression below:

Year(AddYears(Today(),-1)) = substract 1 year of year of today

Year(AddYears(Today(),-2)) = substract 2 year of year of today

Month(AddMonths(Today(),-1)) = substract 1 month of month of today

Month(AddMonths(Today(),-1)) = substract 2 month of month of today