Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date string to datetime SQL Server for a dash-delimited format

How do you convert a string like 2015-10-08 19:56:30.0 to a datetime in SQL Server without having to change languages?

like image 268
Blair Osbay Avatar asked Jun 30 '26 15:06

Blair Osbay


1 Answers

I think this may help you, I have tried this.

Declare @Time as nvarchar(25)
Set @Time = '2015-10-08 19:56:30.0'
Select Cast(@Time As DateTime);
like image 105
Ruhaan Avatar answered Jul 02 '26 10:07

Ruhaan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!