Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date Manipulation
Message
De
06/08/2018 09:10:42
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Titre:
Date Manipulation
Versions des environnements
SQL Server:
SQL Server 2012
Divers
Thread ID:
01661461
Message ID:
01661461
Vues:
52
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform