Hi,
I have a situation where an Insurance Plan can start on a user defined date (say 1st February 2010) and it has a period length of a user defined number of months (say 12 months).
If a user makes a claim in March 2018, the start of the relevant period is 1st February 2018. Or if the claim was on 10th January 2018, the start of the relevant period would be 1st Feb 2017.
I worked out this start date with this code in Visual FoxPro:
DO WHILE m.pdService > GOMONTH(m.tdPeriodStart, m.tnPeriodLength)
m.tdPeriodStart = GOMONTH(m.tdPeriodStart, m.tnPeriodLength)
ENDDO
I am now trying to write a Stored Procedure which has to calculate this date, is there any easy way to do this in TSQL? Or shall I just apply a similar LOOP and keep adding the period Length to the start date?