• Brandie,

    Any chance something like this would work for you?

    If Day(GetDate()) > 26 and Day(GetDate()) <= 31

    Set @LastMonthEnd =

    (Select Max(EndDate)

    from tblAccountingPeriods

    where BeginDate < DateAdd(mm,-1,GetDate())

    and endDate BETWEEN DATEADD(mm, DATEDIFF(mm,0,getdate())-1, 0)

    AND DATEADD(ms, -3, DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))

    Else

    Set @LastMonthEnd = (Select Max(EndDate) from tblAccountingPeriods

    where BeginDate < DateAdd(mm,-2,GetDate())

    and EndDate BETWEEN DATEADD(mm, DATEDIFF(mm,0,getdate())-2, 0)

    AND DATEADD(ms, -3, DATEADD(mm, DATEDIFF(mm,0,getdate())-1, 0))

    To help us help you read this[/url]For better help with performance problems please read this[/url]