6 Replies Latest reply on Dec 14, 2019 1:51 PM by Gaz in Oz

    T-SQL question about converting nvarchar into datetime


      In sql server, the value = 20171030131152 exists in the database as start-time and 20171030131236 as end-time. I want to convert it into date time so that I can calculate elapsed time between start-time and end-time. Below is the code I tried to convert it start-time into datetime declare @starttime nvarchar(255) = '20171030131152' select CAST(@starttime as datetime)