I am sure that I am overlooking some simple thing, I admit that I am still learning various aspects of SQL and the Datepart function is one..
I am inputting a date and returning an invalid quarter, here is the code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION Dbo.FN_Get_Quarter (
-- the parameters for the function here
@date varchar(10)
) RETURNS BIT
AS
BEGIN
RETURN datepart(qq,@date)
END
Here is the test I am using and the returned value...
select dbo.FN_GET_QUARTER('07-14-2010')
...returns 1