Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Time difference in Calendar Month
Message
 
 
To
08/03/2004 12:52:47
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00884020
Message ID:
00884167
Views:
11
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform