从DateTime提取时间(SQL Server 2005) [英] Extracting hours from a DateTime (SQL Server 2005)

查看:191
本文介绍了从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());

DATEPART 文档

这篇关于从DateTime提取时间(SQL Server 2005)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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