Sql server 如何在SQL Server中将军事时间转换为MM/dd/yyyy hh:MM:s tt
我在临时表Sql server 如何在SQL Server中将军事时间转换为MM/dd/yyyy hh:MM:s tt,sql-server,Sql Server,我在临时表DateCreated中有一列,其输出为2/23/2015 17:28,但我想将其转换为2/23/2015 5:28 PM 我当前的代码如下所示: SELECT t1.DateCreated FROM #tempTable t1 在转换函数中使用1和100样式 select convert(varchar(30),DateCreated ,1)+' '+ RIGHT(CONVERT(VARCHAR,DateCreated , 100), 7) AS time 在转换
DateCreated
中有一列,其输出为2/23/2015 17:28
,但我想将其转换为2/23/2015 5:28 PM
我当前的代码如下所示:
SELECT t1.DateCreated
FROM #tempTable t1
在
转换函数中使用1
和100
样式
select convert(varchar(30),DateCreated ,1)+' '+
RIGHT(CONVERT(VARCHAR,DateCreated , 100), 7) AS time
在转换功能中使用1
和100
样式
select convert(varchar(30),DateCreated ,1)+' '+
RIGHT(CONVERT(VARCHAR,DateCreated , 100), 7) AS time
请使用此查询:
SELECT CONVERT(VARCHAR(35),t1.DateCreated,109) FROM #tempTable t1
参考:请使用此查询:
SELECT CONVERT(VARCHAR(35),t1.DateCreated,109) FROM #tempTable t1
引用:您是否尝试过强制转换或转换?你有什么问题?你试过施放或转换吗?您有什么问题?返回日期的格式为2015年1月14日而不是2015年1月14日返回日期的格式为2015年1月14日而不是2015年1月14日