• ZZartin - Thursday, January 19, 2017 2:22 PM

    What happens in January?

    It would be something more like, at least the month and year aren't stored as strings 🙂

    Year = DATEPART(YEAR, DATEADD(MONTH, -1, GETDATE()))
    AND Month = DATEPART(MONTH, DATEADD(MONTH, -1, GETDATE()))

    Sorry I anwsered before noticing there where already plenty anwsers.
    So this anwser can be ignored.

    Year = DATEPART(YEAR, DATEADD(MONTH, -1, GETDATE()))
    AND Month = DATEPART(MONTH, DATEADD(MONTH, -1, GETDATE()))

    ZZartin did give the anwser to the question: How do I get the previous month.

    Januar will give december of the previous year.
    Februar will give januar of the SAME year.
    March ......    etc.

    The question with the 'LAST' month is a bit ambiguous.
    I think that what you wanted is deliverd by ZZartin, if not restate the question.

    Ben
    (Sorry to 'break' in on your anwser ZZartin,but seeing the other posts, I think this needed some extra explanation).