I have a simple query, polling on several crosstab queries with fixed column headers based on relative dates. Basically the infamous Duane Hookom advice for relative dates.
What I cannot do, however, is turn the relative headers (that I am querying) back into ones that make sense. I have attached the SQL code of the simple query as it is:
Code:
SELECT qry_sub_GetSoldLast3Months.[End Item],
qry_sub_GetSoldLast3Months.[Mth-3],
qry_sub_GetSoldLast3Months.[Mth-2],
qry_sub_GetSoldLast3Months.[Mth-1],
qry_sub_GetSoldLast3Months.[Mth0]
and how I would "like" it to be
Code:
SELECT qry_sub_GetSoldLast3Months.[End Item],
qry_sub_GetSoldLast3Months.[Mth-3] AS [dateadd("mm-yy", -3, now())],
qry_sub_GetSoldLast3Months.[Mth-2] AS [dateadd("mm-yy", -2, now())],
qry_sub_GetSoldLast3Months.[Mth-1] AS [dateadd("mm-yy", -1, now())],
qry_sub_GetSoldLast3Months.[Mth0] AS [dateadd("mm-yy", 0, now())]
except of course, this doesn't work, because the aliases are not dynamic i.e. won't return 05-10, 06-10 and 07-10 etc - they will return literally "dateadd(..."
I know there is lots of info on how to do this with a crosstab, transform statement - but my question to the experts out there is: is it possible with a select query?
Any advice appreciated - thanks!!