last day of the first month of the current quarter
Need a query to have the last day of the first month of the current query.
I got a function which returns me only the lastday for the 1quater and third quater,but when i check for 2nd one itw give me error
CREATE FUNCTION GetlastDayOfQuarter
( @pInputDate DATETIME )
RETURNS DATETIME
BEGIN
DECLARE @OutputDate DATETIME
SET @OutputDate = CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' +
CAST(DATEPART(Q, @pInputDate) * 3 - 2 AS VARCHAR(2)) +'/31'
RETURN @OutputDate
END
GO
--select dbo.GetlastDayOfQuarter ('04/01/2008')
please reply:)