Wednesday, May 23, 2007

 

SQL Server: Fastest Way to Create a T-SQL datetime?

Saw this technique to create datetime values over at SQLTeam:

DECLARE @Year smallint
DECLARE @Month smallint
DECLARE @Day smallint
 
SET @Year  = 2007
SET @Month = 5
SET @Day   = 24
 
SELECT DATEADD(month, 12 * @Year - 22801 + @Month, @Day - 1)

(Due to Michael Valentine Jones and Peter Larsson).


    

Powered by Blogger