使用T-SQL获取datetime的时间? [英] Get the time of a datetime using T-SQL?
本文介绍了使用T-SQL获取datetime的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得给定的 datetime
值的时间?
How to get the time for a given datetime
value?
我有一个 datetime
在数据库中,如下所示:
I have a datetime
in database like this:
2010-09-06 17:07:28.170
,只需要时间部分:
17:07:28.170
有没有一个功能
推荐答案
只是为了从SQL Server 2008中添加一个TIME数据类型,从那时起,您可以执行以下操作: p>
Just to add that from SQL Server 2008, there is a TIME datatype so from then on you can do:
SELECT CONVERT(TIME, GETDATE())
对于那些使用SQL 2008+的用户而言,可能会遇到这个问题。
Might be useful for those that use SQL 2008+ and find this question.
这篇关于使用T-SQL获取datetime的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文