I'm currently using the following for data trends for the last 12 months. However, I need to not include the current month (i.e. August now) and just the last 12 months through last month (July). Any ideas on how I can modify this to have August excluded?
"timestampadd" suggests you are using something other than Microsoft SQL Server?
This is a Microsoft SQL Server forum, so it might be that there is no=one here familiar with the flavour of SQL that you are using - assuming you are not using MS SQL telling us what it is will establish if anyone here thinks they can help or not!
Since you do not bother with DDL for us, I will dimply say that you need a julianized ordinal month in your calendar table and let you figure it out. Why should we bother with DML? The worst way is to do temporal math with the proprietary temporal functions. Cannot optimize, cannot port and it is slow. .