Skip to content
Advertisement

Get DateTime from text

How to separate and display only the DateTime from the string?

I have a column that holds this data:

I used this query to separate out the time:

and it returned the same lines. String didn’t get filtered

When I tried using this statement:

I got this error

Conversion failed when converting date and/or time from character string.

How can I overcome time and get the below expected result?

Advertisement

Answer

With patindex you can locate the time pattern.

CommentTime
09:25:00
10:17:27
07:00:48
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement