• There are a ton of date routines to do all sorts of things.

    Here is a very simplistic example:

    select Month(dateadd(mm, -1, '2016-01-15')) Mon,

    Year(dateadd(mm, -1, '2016-01-15')) Yr

    You can build on this and do all sorts of stuff. Check out datediff, datepart, datename, to name just a few.

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/