Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Time difference in Calendar Month
Message
 
 
À
08/03/2004 12:52:47
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00884020
Message ID:
00884167
Vues:
12
This message has been marked as the solution to the initial question of the thread.
>Yes, the EndDate will always be the end of the month in this scenario.

Try
DECLARE @FirstOfMonth datetime
-- Calculate the first of the month
@FirstOfMonth = DATEADD(mm,DATEDIFF(mm,0,EndDate),0)
select Claim_Reference, Claim_Registered_Date, EndDate,
CASE
WHEN overall_stat = "Outstanding"
     AND Claim_Registered_Date >= @FirstOfMonth
		THEN "01 - Up to 1 Month"

WHEN overall_stat = "Outstanding"
     AND Claim_Registered_Date >= DATEADD(mm, -2, @FirstOfMonth)
     AND Claim_Registered_Date < @FirstOfMonth
		THEN "02 - 1 to 2 Months"

WHEN overall_stat = "Outstanding"
     AND Claim_Registered_Date >= DATEADD(mm, -6, @FirstOfMonth)
     AND Claim_Registered_Date < DATEADD(mm, -2, @FirstOfMonth)
		THEN "03 - 2 to 6 Months"
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform