Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I have a slight problem with addmonths function.
set errormode = 0;
Let vActualYearAndMonth = date(Today(), 'DD-MM-YYYY');
for i = 0 to 5
let test = addmonths ($(vActualYearAndMonth),-$(i));
NEXT i
As today is 01-12-2014, it should return:
01-12-2014
01-11-2014
01-10-2014
01-9-2014
01-8-2014
but it returns
05-12-99
05-11-99
05-10-99
05-9-99
05-8-99
Do you have an idea why is this happening?
set errormode = 0;
Let vActualYearAndMonth = Today();
for i = 0 to 5
let test = Date(addmonths ('$(vActualYearAndMonth)',-$(i)), 'DD-MM-YYYY');
NEXT
Hi Nemanja,
I think your addmonths statement is calculating the value of vActualYearAndMonth rather than taking it as a date - wrapping it in the DSE will cause it to return it's numerical value of -2025.
Try removing the $( ) from the variable name and see if that works.
Thanks.
set errormode = 0;
Let vActualYearAndMonth = Today();
for i = 0 to 5
let test = Date(addmonths ('$(vActualYearAndMonth)',-$(i)), 'DD-MM-YYYY');
NEXT