按时间以美国格式输出日期时间的最佳方法是什么。我希望看到输出类似于“03/10/2017 18:16:46”
答案 0 :(得分:2)
select convert(varchar(10),getdate(),101)+' '+convert(varchar(8),getdate(),114)
rextester演示:http://rextester.com/CRP29768
返回:03/10/2017 21:30:24
在sql server 2012+中,您可以使用format()
select format(getdate(), 'MM/dd/yyyy HH:mm:ss')
返回:03/10/2017 21:30:24
但format()
可能会慢一点,请看一下:format()
is nice and all, but… - Aaron Bertrand