Jul 1, 2010

Write a function to Get time part of datetime value

CREATE FUNCTION dbo.TimePart
  ( @fDate datetime )
RETURNS varchar(10)
AS
BEGIN
  RETURN ( CONVERT(varchar(7),right(@fDate,7),101) )
END
GO

o/p
SELECT dbo.TimePart('11/11/2000 11:15AM')

11:15AM

No comments:

Post a Comment