det här fungerar
declare @from datetime
SET @from =CONVERT(DATETIME, '01/01/2000 12:00 pm')
Följande testades.
CREATE FUNCTION formatit(
@fromtime VARCHAR(50) -- varchar
)
RETURNS DATETIME
AS
BEGIN
DECLARE @from datetime
IF (CHARINDEX('NOON',@fromtime,0)) = 0
SET @from = CONVERT(DATETIME, @fromtime)
ELSE
SET @from =CONVERT(DATETIME, '01/01/2000 12pm')
RETURN(@from)
END
SELECT dbo.formatit('04/12/2011 NOON ')