Home > other >  Extract datetime from string with chars
Extract datetime from string with chars

Time:03-07

I have the following string

["07/03/22 10:29:00","1.08203","1.08205","1.08177","1.08177"

And I want to get just the date

07/03/22 10:29:00 

I tried to use CONVERT function, but it doesn't works I think because the chars inside.

Thanks

CodePudding user response:

If you are using SQL Server 2016 and above, the following query will work by using enter image description here

The STRING_SPLIT solution is cost is 792, the SUBSTRING solution cost is 12.

  •  Tags:  
  • sql
  • Related