Technical Article

Get rid of times as fast as possible!

,

This script shows the way, how to remove a time from datetimes.
Do not move this code to UDF, it would run at least 6 times slower.

/* Declaration */declare @DateTime datetime
set @DateTime='20030331 23:59:59.997'

/*  THE FASTEST AS I KNOW, but nondeterministic (for SQL Server 2000) */
SELECT CONVERT(DATETIME,DATEDIFF(DAY,0,@DATETIME))


/* Deterministic, but 20x slower */select convert(datetime,convert(char(8),@Datetime,112),112)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating