什么是“时间"的内置功能 [英] What is built-in function for 'time'

查看:163
本文介绍了什么是“时间"的内置功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我得到类似''time"不是公认的内置函数名称"之类的错误.

In the following code I get the error like " ''time'' is not a recognised built-in function name".

SELECT YEAR(startdt) AS [Year],MONTH(startdt) AS [Month], DAY(startdt) as [day],time(startdt) as [time] COUNT(*) from visit Group By YEAR(startdt), MONTH(startdt),day(startdt),time(startdt)



列名"startdt"的数据类型为"datetime".
谁能建议我如何纠正此错误.



The column name ''startdt'' is of ''datetime'' datatype.
Can anyone suggest me how to rectify this error.

推荐答案

看看...

http://dev.mysql.com/doc/refman/5.5/zh_/date-and-time-functions.html [ ^ ]
Have a look...

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html[^]


您应该尝试以下时间:
You should try this for time:
SELECT LTRIM(RIGHT(CONVERT(VARCHAR(20), GETDATE(), 100), 7))


请阅读日期和时间数据类型和功能-SQL Server (2000、2005、2008、2008 R2、2012) [


Please read Date and Time Data Types and Functions - SQL Server (2000, 2005, 2008, 2008 R2, 2012)[^] for more details.

Hope it helps!

--Amit


您必须使用此...
You have to Use this...
SELECT YEAR(startdt) AS [Year],MONTH(startdt) AS [Month], DAY(startdt) as [day],Convert(Time,startdt) as [time], COUNT(*) from visit 
Group By YEAR(startdt), MONTH(startdt),day(startdt),Convert(Time,startdt)


如果您想与Am/Pm相处,则必须使用


If you want to get along with Am/Pm u have to use

SELECT RIGHT(CONVERT(VARCHAR(25), GETDATE(), 22),11)



链接:
时间MSDN [ ^ ]



Links: Time MSDN[^]


这篇关于什么是“时间"的内置功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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