Reputation: 39
I'm trying to get the year of the previous month.
For example in July 2017 I want result 2017. But in January 2017 I want result 2016 and in Feb 2017 I want result 2017. Using SQL Server.
Upvotes: 1
Views: 3542
Reputation: 20794
sql server?
select datepart(year, dateadd(month, -1, getdate()))
Upvotes: 2