Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date Manipulation
Message
From
06/08/2018 09:10:42
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Title:
Date Manipulation
Environment versions
SQL Server:
SQL Server 2012
Miscellaneous
Thread ID:
01661461
Message ID:
01661461
Views:
51
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?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform