sqlserver中格式化时间:yyyyMMddHHmmss->yyyy-MM-dd HH:mm:ss
sqlserver中格式化时间:yyyyMMddHHmmss->yyyy-MM-dd HH:mm:ss
-- bigint 格式化时间 yyyy-MM-dd HH:mm:ss select FORMAT(20161207160310,'####-##-## ##:##:##') time -- varchar 格式化时间 yyyy-MM-dd HH:mm:ss select FORMAT(cast('20161207160310' as bigint),'####-##-## ##:##:##') time select cast(FORMAT(cast('20161207160310' as bigint),'####-##-## ##:##:##') as datetime) time select cast(FORMAT(cast('20161207160310' as bigint),'####-##-## ##:##:##') as datetime2(0)) time
将秒转换为时分秒
declare @li_duration int = 1000 SELECT CONVERT(VARCHAR(10),@li_duration/3600)+' hours, '+CONVERT(VARCHAR(10),@li_duration%3600/60)+' minutes, '+CONVERT(VARCHAR(10),@li_duration%3600%60)+' seconds'