ShortTime 

Posted by Philip Leitch Thursday, June 04, 2009 8:49:56 PM

IF EXISTS (SELECT 'x' FROM   sysobjects WHERE  name = 'ShortTime')
 DROP FUNCTION ShortTime
GO
CREATE FUNCTION ShortTime
 (@InTime as datetime)
RETURNS datetime
AS
BEGIN

/*
Author: Philip Leitch
Date: 2001
Purpose: Returns just the time component of a datetime or smalldatetime variable.
Copyright: Philip Leitch 2001
Licensing: This code may be used or modified but if the code is included in a software package attribution to me must be made.
Liability: The developer assumes all liability when using this code.
*/
 RETURN @InTime - cast(floor(cast(@InTime as float)) as smalldatetime)
End
GO

-- =============================================
-- Example to execute function
-- =============================================
SELECT dbo.ShortTime(getdate())



Copyright 2009 Philip Leitch