Maybe this code will give you an idea.
DECLARE @FYint=14,
@P int=3;
DECLARE @Date date
SET @Date = CAST( @FY as CHAR(2)) + RIGHT( '0' + CAST( @P AS varchar(2)), 2) + '01'
SELECT @Date LastPeriod, DATEADD( MM, -11, @Date) AS FirstPeriod.
SELECT DATEADD( MM, -n, @Date)
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11))Tally(n)
ORDER BY n DESC
As Lynn said, we can't see your information, so any further help would need some help from you. Post the information that Lynn asked and we'll be glad to help.