• DATEADD(mm, DATEDIFF(mm, 0, GETDATE()) - 1, 0)

    Is getting the first day of previous month.

    DATEADD(mm, DATEDIFF(mm, 0, GETDATE()), 0)

    Is getting the first day of current month.

    - '00:00:01'

    Is substracting one second to get only values from previous month because BETWEEN limits are inclusive.

    There are ways to rewrite the code, but this might be the best in terms of performance and flexibility. It's basically adding months to a base date (zero or 1900-01-01) to eliminate days and time. You could use the same functionality for other datetime parts.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2