Quantcast
Channel: convert string to date
Viewing all articles
Browse latest Browse all 10

convert string to date

$
0
0

create table #temp (col1 varchar(200))
insert #temp values ('abcd_efgh_stry_2018-11-02.xml'),('ghjk_tfgh_2018-11-02.xml')

select *,convert(date,substring(col1,patindex('%[0-9]%',col1),patindex('%.xml%',col1)-patindex('%[0-9]%',col1)))
from #temp

Mark as answer if it helps. Thanks.

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>