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.
sql server?
select datepart(year, dateadd(month, -1, getdate()))
select year(dateadd(month,-1,GETDATE()));