• I think this method with the nested DATEADD/DATEDIFF is simple and has the advantage of eliminating the time part.

    select

    a.DT,

    [LastDayOfPriorMonth] =

    dateadd(mm,datediff(mm,-1,a.DT)-1,-1),

    [LastDayOfPriorYear] =

    dateadd(yy,datediff(yy,-1,a.DT)-1,-1)

    from

    ( -- Test Dates

    select top 32

    DT = getdate()-1+

    row_number() over (order by object_id)

    from sys.objects

    ) a

    order by

    a.DT

    Results:

    DT LastDayOfPriorMonth LastDayOfPriorYear

    ----------------------- ----------------------- -----------------------

    2013-01-01 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-02 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-03 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-04 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-05 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-06 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-07 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-08 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-09 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-10 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-11 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-12 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-13 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-14 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-15 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-16 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-17 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-18 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-19 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-20 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-21 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-22 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-23 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-24 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-25 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-26 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-27 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-28 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-29 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-30 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-01-31 20:47:27.733 2012-12-31 00:00:00.000 2012-12-31 00:00:00.000

    2013-02-01 20:47:27.733 2013-01-31 00:00:00.000 2012-12-31 00:00:00.000