In MS Access 2010 I am trying to declare and initialize a variable in a query, then display the contents of that variable. The reason for doing this is to use the parameter in a more complicated query as part of a filter. Please note that for this particular case this task must be done in a query object, not in VBA. Here is the code thus far:
PARAMETERS @Date DATE; SELECT TOP 1 FORMAT(LastUpdated, "yyyy-mm-dd") AS @Date FROM Table1 GROUP BY FORMAT(LastUpdated, "yyyy-mm-dd") ORDER BY FORMAT(LastUpdated, "yyyy-mm-dd") DESC; SELECT @Date;
This results in an error message: "Characters found after end of SQL statement."
If this can be modified to work the last line of code will be replaced with the more complex query that needs to use @Date in a filter. The other requirement is that it has to be contained within one query object.