Any way to convert this varchar -> "18-Jan-2015 12:43:51" to datetime in SQL database? Thanks.
Just like everybody said above, the best way to do it is either with convert or cast, besides, this is very basic sql
here are both cases:
SELECT CAST('18-Jan-2015 12:43:51' AS DATETIME) AS DATE
SELECT CONVERT (DATETIME, REPLACE('18-Jan-2015 12:43:51', '-', ' '))
尝试这个:
SELECT (CONVERT(DATETIME,LEFT('18-Jan-2015 12:43:51',23),101))
您可以使用如下语句
Select convert(datetime, replace('18-Jan-2015 12:43:51', '-', ' '))
SELECT CAST('18-Jan-2015 12:43:51' AS DATETIME)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.