Reputation: 513
I'm getting this string "20150930 092622_647" and have to save it to a datetime column but I can convert it.
I know about the CONVERT but the closest expression style I found was 112 the problem is the time not the date here.
CONVERT(DATETIME, REPLACE( '20150930 092622_647', '_', ' '), 112)
Upvotes: 1
Views: 189
Reputation: 6713
You don't need the style unless you are converting the other way... from a datetime
to a character based type.
This expression will probably get you what you need:
select convert(datetime,stuff(stuff(stuff('20150930 092622_647',16,1,'.'),14,0,':'),12,0,':'))
Upvotes: 3