Remove Time Component from Date

Posted: October 1, 2010 in SQL Server 2005

To remove the time component from a date, you can try the following function:

-- Function to removes the time component from a date
CREATE FUNCTION dbo.dbf_trunc_date  
               (@pdt_datetime DATETIME) 
RETURNS DATETIME  
AS
BEGIN  
   RETURN CONVERT(DATETIME, FLOOR(CONVERT(NUMERIC(18,6), @pdt_datetime)));  
END;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s