Yes, define your variable in the script using LET, i.e.
Let vTest2 = Text(Date(Today(),'YYYY'));
or as Gybert suggested using Year() function.
If you define it in the variable overview, the Dollar sign expansion in the script will contain the equal sign, leading to
WHERE YEAR <= =Text(Date(Today(),'YYYY'))
Alright, that does the trick
Using let the values are created during script execution time but that shouldn't be a problem in my current case. Sadly there's only one answer to mark as the right one. Ruben got me on the right track at first but yours is more precisely.
I also saw the invalid syntax but hoped for another mechanism which unlike dollar expansion would evaluate the function at first.
Gysbert mentioned the Year() function and this one works well but sometimes it is important how the data are formatted and date() gives a better handling imho - combined with text() or num() it should even return the right data type.
Dollar sign expansion will anyway expand the variable to plain constant number in the script code before parsing, so no need to worry about right data types.
I would go for just using (as suggested above)
LET vMaxYear = Year(Today() );
It's just much easier to understand.
Well I don't want to fight about it but in my case vMaxYear might be used in comparing combined fields of year and month so it's neccessary to have a 4 char year and a 2 char month - using text(date(today(),'MM')) it is save to have leading 0s for string operations whilst set analysis does not care.
Just my two cents - maybe I'll see the perks of year(), month(),.. in the future
Hi, If you do LET vMaxYear = Date(Today(), 'YYYY'); --> QV stores the string 2015 and the value 22/10/2015
If you create a text box with expression "=AddMonths(vAño, 3)" --> returns 22/01/2016
So be aware of what value you're really saving and if you go with the date version consider to use EndYear(), EndMonth(), Today()... as it will change the value you're storing (it will show all as '2015').
If you use LET vMaxYear = Text(Date(Today(), 'YYYY')); --> Then you're storing a text, not a date, and date functions like AddMonths() will fail.