Reputation: 189
What function can I use to get the previous months date in the format yyyy-mm . This is what I have tried.
SELECT FORMAT (getdate(), 'yyyy-MM') as date
Upvotes: 0
Views: 104
Reputation: 175556
You could use DATEADD:
SELECT FORMAT (DATEADD(mm, -1, getdate()), 'yyyy-MM') as date
Upvotes: 5