I'm trying to figure how to build my query to where it automatically sets the date range for the previous month. This will allow me to automate my query instead of having to manually change the date range each month. I searched for questions similar to mine but was unable to find anything for exactly what I'm trying to do.
Edit: not sure why this is being down voted. Did I forget to include something, or is this just an overall stupid question?
You just need to extract the month from the Current date and compare it with the extracted month of your data.
SELECT * FROM yourTable WHERE (month(CURRENT DATE) - 1) = month(yourColumn) AND year(CURRENT DATE) = year(yourColumn)
Something like this. I never used DB2 but it should work