使用SQL Server 2005和2008使用SQL查询从DateTime列获取时间 [英] Get only Time from DateTime column using SQL query using SQL Server 2005 and 2008

查看:111
本文介绍了使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆