从 DateTime 中提取小时数 (SQL Server 2005) [英] Extracting hours from a DateTime (SQL Server 2005)
本文介绍了从 DateTime 中提取小时数 (SQL Server 2005)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用Day(Date())
、Month(Date())
来提取月份和日期.我无法使用 HOUR(Date())
提取小时数.我收到以下错误.
I can extract the month and day by using Day(Date())
, Month(Date())
. I can't extract hours, with HOUR(Date())
. I get the following error.
'HOUR' is not a recognized built-in function name.
如何提取小时数?
推荐答案
SELECT DATEPART(HOUR, GETDATE());
这篇关于从 DateTime 中提取小时数 (SQL Server 2005)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文