Don't know if this matters but this should be all you need
WHERE [Calendar Date]<='$(vMaxDate)';
Not even sure you need the string markers there but just try it both ways. You don't need the parenthesis after WHERE but I'm not sure why it matters. Also put WHERE on the next line... it's touching the other ')'. Not sure if that matters either.. but give it a shot.
My guess is that the problem is that the end parenthesis in the "table is [whatever])" and the WHERE clause don't have a space between them.
it has to do with the date comparizons. Your variable vMaxDate may contain either the formatted date string or the numeric part, but not both (variables don't get the priviledge of being dual). It depends on how you assigned it.
Try playing with the condition:
- without quotes, using formatted string?
- without quotes, using numeric values?
I think Excel should work well with the numeric values, since it's using the same calculation formula for dates...