SQL - Get the previous month's month and date
Posted on 2004-10-13
I am using SQL Server Query Analyzer. So, in SQL is it possible to get the previous month's year and date? So, for example, when the current month is October how can I get September 2004 and then store it as a value? But here is the kicker....I would like to convert the value to '200409'?
My current code is:
SELECT * FROM Table WHERE datereceived LIKE '200409%'
I would like it to be
SELECT * FROM Table WHERE datereceived LIKE 'lastmonthvariable%'
Thanks in advance