简体   繁体   中英

SQL Convert varchar value to datetime

我有一个与SQL日期时间相同的varchar值显示。我需要将其转换为SQL日期时间格式。任何人都可以帮我.........

2014-07-28 18:05:14(varchar) --> 2014-07-28 18:05:14(DateTime)

你可以试试看

cast('2014-07-28 18:05:14' AS DATETIME)
select cast('2014-07-28 18:05:14' as datetime)

在MySQL中,您可以尝试此操作。

select str_to_date('2014-07-28 18:05:14');

Probably you can use

Convert(Varchar(20),'2014-07-28 18:05:14',106)

or

Convert(DateTime,'2014-07-28 18:05:14',106)

more can be described if you can provide more detail about your code.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM