ShortDate
Posted by Philip Leitch
Thursday, June 04, 2009 8:36:50 PM
IF EXISTS (SELECT 'x' FROM sysobjects WHERE name = 'ShortDate')
DROP FUNCTION ShortDate
GO
CREATE FUNCTION ShortDate
(@InDate as datetime)
RETURNS datetime
AS
BEGIN
/*
Author: Philip Leitch
Date: 2001
Purpose: Returns just the date 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 cast(floor(cast(@InDate as float)) as smalldatetime)
End
GO
-- =============================================
-- Example to execute function
-- =============================================
SELECT dbo.ShortDate(getdate())
Copyright 2009 Philip Leitch