Thanks to everyone who replied so promptly.

-----Original Message-----
From: Robertson-Ravo, Neil (RX)
[mailto:[EMAIL PROTECTED]
Sent: Monday, July 07, 2003 7:29 AM
To: CF-Talk
Subject: RE: SQL quickie


if you are on SQL 2000 this is a UDF which sort this out..

CREATE FUNCTION dbo.LastMonthDay  ( @Date datetime )

RETURNS datetime

AS
BEGIN
RETURN (CASE WHEN MONTH(@Date)= 12
THEN DATEADD(day, -1, CAST('01/01/' + STR(YEAR(@Date)+1) AS DateTime))
ELSE DATEADD(day, -1, CAST(STR(MONTH(@Date)+1) + '/01/' + STR(YEAR(@Date))
AS DateTime))
END)
END

GO


call it thus : 

SELECT dbo.LastMonthDay('07/07/03')
GO





-----Original Message-----
From: Eric Creese [mailto:[EMAIL PROTECTED]
Sent: 07 July 2003 13:22
To: CF-Talk
Subject: SQL quickie


I want to be able to take a value of getdate() and then from that determine
the last day of the month that getdate() is in. I will be doing this in a
stored procedure.

For instance, today is 7/7/2003 I want to output 7/31/2003 to the next part
of the procedure.

Eric


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to