The T-SQL code is as follows, Still work in progress so bit messy.
Declare @StartDate13 datetime, @EndDate datetime
select @StartDate13 = dateadd(mm,datediff(mm,0,DateAdd (mm,-13,getdate())),0)
select @EndDate = DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)-1
print...