Here’s a query that converts a Date to a String in SQL Server:
DECLARE @Dt as DateTime
SET @Dt = '2010-02-22 11:45:17'
SELECT CONVERT(CHAR(8), @Dt, 112)+ REPLACE(CONVERT(CHAR(8), @Dt, 114), ':', '')
In the query shown above, the style value 112 gives an output of yymmdd and a style value 114, gives an output of hh:mi:ss:mmm(24h). To display the milliseconds too, change Char(8) to Char(12).