仅从2次获取数据 [英] Get data from only 2 time
问题描述
i我这样做
选择计数(日期)为number_of_queries
来自查询
其中日期
日期
2012-01-05 01:00:00.0
2013-06- 01 09:00:00.0
2014-01-02 04:00:00.0
2013- 09-10 13:00:00.0
2012-01-05 14:00:00.0
2013-06-01 19:00:00.0
2014-01-02 14:00:00.0
2014-09-10 13:00:00.0
尝试:
SELECT * FROM MyTable
WHERE CAST( [ date ] as TIME ) BETWEEN ' 01:00:00' AND ' 05:00:00'
没有注意到它是MySQl:
SELECT * FROM MyTable
WHERE TIME ([ date ]) BETWEEN ' 01:00:00' AND ' 05:00:00'
尝试这样的事情:
SELECT DateField
FROM TableName
WHERETIME (DateField) BETWEEN ' 01:00:00' AND ' 05:00:00'
如需了解更多信息,请参阅:
https://dev.mysql.com/doc /refman/5.7/en/date-and-time-functions.html [ ^ ]
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_time [ ^ 一>
i have table in there is a coloumn name date. I just want to fetch the data from table between 1 a.m and 5 a.m (both inclusive) not considering the date.
i am doing like this
select count(date) as number_of_queries
from query
where date
DATE
2012-01-05 01:00:00.0
2013-06-01 09:00:00.0
2014-01-02 04:00:00.0
2013-09-10 13:00:00.0
2012-01-05 14:00:00.0
2013-06-01 19:00:00.0
2014-01-02 14:00:00.0
2014-09-10 13:00:00.0
Try:
SELECT * FROM MyTable WHERE CAST([date] as TIME) BETWEEN '01:00:00' AND '05:00:00'
Didn't notice it was MySQl:
SELECT * FROM MyTable WHERE TIME([date]) BETWEEN '01:00:00' AND '05:00:00'
Try something like this:
SELECT DateField FROM TableName WHERE TIME(DateField) BETWEEN '01:00:00' AND '05:00:00'
For further information, please see:
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html[^]
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_time[^]
这篇关于仅从2次获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!