• So you just need the year as parameter 1, so you know which July 1st you're after. Then the number of periods, which equates to the number of months. You could use DATEADD to add the required number of months to get the start of the end month (subtracting 1 of course, because '1' would mean just July).

    At this point your end date would be set for the start of whichever month, so you need to use that date to calculate the end of that month. There is an article on this site for calculating various dates, or an article by Robyn Page and Phil Factor https://www.simple-talk.com/sql/learn-sql-server/robyn-pages-sql-server-datetime-workbench/ which has a calculation for getting the last day of the month.

    If you need to you can now use DATEDIFF to get the number of days between both.