Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Trouble with variables

Hi everybody,

I have a selection on date like 18/03/2014

THEN max(DateExerNum) = 18/03/2014

who can explain why

This

SET vPriorMaxDate    = "=addmonths(max(DateExerNum), -12)";

returns  31/12/1899     WRONG VALUE

This

SET vPriorMaxDate    = "=(max(DateExerNum)-365)";

returns 18/03/2013  RIGHT VALUE

Best regards

Chris

1 Solution

Accepted Solutions
Not applicable
Author

Thank you Gysbert

you gave me the missign clue

SET vPriorMaxDate    = "=num(addmonths(max(Bud.DateExerNum), -12))";

best regards

Chris

View solution in original post

7 Replies
tresesco
MVP
MVP

Could you post a sample that demonstrates the issue?

ThornOfCrowns
Specialist II
Specialist II

Hi, I did a little inline load and put your two SET expressions in the load script. Both return the same correct result when used in a text box, for example.

What are you doing to set DateExerNum?

Not applicable
Author

Its evaluating the first expression. But I dont understand the dfference between let and set here..both of them working in a similar way. I have used this exp:

set v2="=addmonths(max(Date),-12)";

This works fine.

ThornOfCrowns
Specialist II
Specialist II

     Let: Calculates the expression assigned to it and sets the expression result to the variable.

     Set: Assigns the value(or expression which is after the equal sign) as it is without compute.


Example:

     Set vVar=2+3; //vVar has the expression 2+3 as value and you have to compute it using $(vVar) which returns 5

     Let vVar=2+3;//vVar has the computed value 5

It doesn't matter too much with strings, as in this case, as it works either way.

Gysbert_Wassenaar

The addmonths function will return a date as a dual value, e.g. with a numeric value and as a formatted string. That string is probably not interpreted as a date when you use it later, but instead as 18 divided by 3 divided by 2013. That returns a very small number (close to 0) that when shown as a date returns a date close to the start of the calendar (day zero).


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert,

Yes i could check the result hasn't a date format but i can't use date function like

SET vPriorMaxDate    = "=date(addmonths(max(DateExerNum), -12))";

which returns the same wrong result

Thank you everybody for your answers

Chris

Not applicable
Author

Thank you Gysbert

you gave me the missign clue

SET vPriorMaxDate    = "=num(addmonths(max(Bud.DateExerNum), -12))";

best regards

Chris