Posted By

pauliehaha on 02/09/09


Tagged


Versions (?)

Date From DateTime Function


 / Published in: SQL
 

  1. /****** Object: UserDefinedFunction [dbo].[fnDateFromDateTime] Script Date: 11/26/2007 09:09:00 ******/
  2. IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[fnDateFromDateTime]') AND xtype IN (N'FN', N'IF', N'TF'))
  3. DROP FUNCTION [dbo].[fnDateFromDateTime]
  4.  
  5. -- Gets the date part of a datetime input
  6. CREATE FUNCTION dbo.fnDateFromDateTime
  7. (
  8. @DateTime datetime
  9. )
  10. RETURNS datetime
  11. AS
  12. BEGIN
  13. RETURN (CONVERT(datetime, CONVERT(varchar(10), @DateTime, 101)))
  14. END

Report this snippet  

You need to login to post a comment.