Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a simple date slider with min and max value and set the format to d-m-y
The value is stored in a variable called v_today
I thought i could calculate other variables based on the stored value
I tried a lot different expressions and formats but I get strange results.
When I add a variable with expression =addyears($(v_today),1) I get strange results.
Please have a look at enclosed qvw and tell me what i am doing wrong
The AddYears function returns a date. Your variable gets the value of that date, but not the numeric value of that date, but its text representation: 23-10-2018. When you evalutate that value with dollar expansion you get $(23-10-2018) which gives the result of 23 minus 10 minus 2018. That's -2005. If you don't dollar expand it but use it in the Date function you get Date(23-10-2018) which is Date(-2005) which gives the resulting date 4-7-1894.
So how do you fix that? One way is to create your variable as =num(addyears(v_today, -1)) so that it always gets a numeric value which can be evaluated correctly in a dollar expansion and also works correctly as input for the Date function.
The AddYears function returns a date. Your variable gets the value of that date, but not the numeric value of that date, but its text representation: 23-10-2018. When you evalutate that value with dollar expansion you get $(23-10-2018) which gives the result of 23 minus 10 minus 2018. That's -2005. If you don't dollar expand it but use it in the Date function you get Date(23-10-2018) which is Date(-2005) which gives the resulting date 4-7-1894.
So how do you fix that? One way is to create your variable as =num(addyears(v_today, -1)) so that it always gets a numeric value which can be evaluated correctly in a dollar expansion and also works correctly as input for the Date function.