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.
2007-10-02 (first published: 2002-06-20)
15,451 reads
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)