Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

CONVERT DATETIME to TIME and remove seconds and milliseconds

$
0
0
Hello Folks,How can I convert StartTime2 so that it equals StartTime1DECLARE @StartTime1 TIMESET @StartTime1 = '17:41:00.0000000'SELECT @StartTime1DECLARE @StartTime2 DATETIMESET @StartTime2 = '2016-09-22 17:41:14.810'SELECT @StartTime2I can convert StartTime2 to time OKSELECT CONVERT(TIME,@StartTime2)My desired result is a conversion of @StartTime2 to '17:41:00.0000000' (not 17:41:14.8100000)This is a variation of the old 'How can I remove the time from DATETIME', instead it is 'How can I remove seconds and milliseconds from TIME'.

Viewing all articles
Browse latest Browse all 3145

Trending Articles