SQL Server 将 Varchar 转换为日期时间
我有这种日期格式:2011-09-28 18:01:00(在 varchar 中),我想将其转换为日期时间更改为这种格式 28-09-2011 18:01:00.我该怎么做?
I have this date format: 2011-09-28 18:01:00 (in varchar), and I want to convert it to datetime changing to this format 28-09-2011 18:01:00. How can I do it?
推荐答案
SELECT CONVERT(Datetime, '2011-09-28 18:01:00', 120) -- to convert it to Datetime
SELECT CONVERT( VARCHAR(30), @date ,105) -- italian format [28-09-2011 18:01:00]
+ ' ' + SELECT CONVERT( VARCHAR(30), @date ,108 ) -- full date [with time/minutes/sec]
相关文章