Friday, July 26, 2019

TSQL: Convert string in mm:ss.ms format to time

The following statement converts time string (nvarchar) in mm:ss.ms format to Time

print DATEADD(ms, (ISNULL(LEFT(TRY_PARSE(RIGHT(ISNULL(LEFT(RIGHT(@timeString,LEN(@timeString)-CHARINDEX(':',@timeString)), 5), '0'),LEN(ISNULL(LEFT(RIGHT(@timeString,LEN(@timeString)-CHARINDEX(':',@timeString)), 5), '0'))-CHARINDEX('.',ISNULL(LEFT(RIGHT(@timeString,LEN(@timeString)-CHARINDEX(':',@timeString)), 5), '0'))) AS INT), 2), 0)) * 10,
DATEADD(s, ISNULL(TRY_PARSE(LEFT(ISNULL(LEFT(RIGHT(@timeString,LEN(@timeString)-CHARINDEX(':',@timeString)), 5), '0'),LEN(ISNULL(LEFT(RIGHT(@timeString,LEN(@timeString)-CHARINDEX(':',@timeString)), 5), '0'))-CHARINDEX('.',ISNULL(LEFT(RIGHT(@timeString,LEN(@timeString)-CHARINDEX(':',@timeString)), 5), '0'))) AS INT), 0),
DATEADD(mi, ISNULL(TRY_PARSE(LEFT(@timeString,CHARINDEX(':',@timeString)-1) AS INT), 0), '0:0')))

No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...