你可以使用这个方法,只需要将
getdate()
替换为你的字段即可:
select convert(char(10), getdate(), 103) + ' '
+ convert(char(8), getdate(), 108)
这将为您提供结果:
14/03/2012 17:05:47
如果你只想要小时和秒数,则:
select convert(char(10), getdate(), 103) + ' '
+ Left(convert(char(8), getdate(), 108), 2) + ':'
+ Right(convert(char(8), getdate(), 108), 2)
这里有一个有用的链接,包含日期/时间转换:
http://anubhavg.wordpress.com/2009/06/11/how-to-format-datetime-date-in-sql-server-2005/
根据您的评论,应该是
dd/mm/yyyy hh:mm
,那么查询语句将如下:
select convert(char(10), getdate(), 103) + ' '
+ Left(convert(char(8), getdate(), 108), 5)
没有使用 LEFT()
select convert(varchar(10), getdate(), 103) + ' '
+ convert(char(5), getdate(), 108)