使用SQL Server 2005和2008使用SQL查询从DateTime列获取时间 [英] Get only Time from DateTime column using SQL query using SQL Server 2005 and 2008
本文介绍了使用SQL Server 2005和2008使用SQL查询从DateTime列获取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我 想要 to get 仅 时间 来自 DateTime 列 使用 SQL query 使用 SQL 服务器 2005 和 2008 默认 输出:
AttDate
==
< span class =code-leadattribute> 2011-02-09 13:09:00
2011-02-09 14:10:00
我是喜欢 此 输出:
AttDate 时间
==
2011-02-09 13:09:00 13:09
2011-02- 09 14:10:00 14:10
解决方案
:
选择演员表(你的专栏作为时间)[时间]
$来自yourtable的b $ b
检查此链接:
sql-server- get-time-in-hourminute-format-from-a datetime-get-date-part-only-from-datetime / [ ^ ]
SELECT (getdate()),substring( CONVERT ( VARCHAR ,GETDATE(), 108 ), 0 , 6 ) AS 时间跨度>
I want to get only Time from DateTime column using SQL query using SQL Server 2005 and 2008 Default output:
AttDate
==
2011-02-09 13:09:00
2011-02-09 14:10:00
I'd like this output:
AttDate Time
==
2011-02-09 13:09:00 13:09
2011-02-09 14:10:00 14:10
解决方案
in Sqlserver2008:
Select cast(your Column as time) [time]
from yourtable
Check this link:
sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/[^]
SELECT (getdate()),substring(CONVERT(VARCHAR, GETDATE(), 108),0,6) AS Time
这篇关于使用SQL Server 2005和2008使用SQL查询从DateTime列获取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文