presto sql: select 日期时间之前或之后的数据

presto sql: select the data that before or after a datetime

有table叫t1,有列id,created_at,text,例如,如下table:

id                created                      text
1       Thu Jun 30 01:00:57 +0000 2016        I like this movie1
2       Thu Jun 30 02:59:57 +0000 2016        I like this movie2
3       Thu Jun 30 03:49:57 +0000 2016        I like this movie3
4       Thu Jun 30 04:59:50 +0000 2016        I like this movie4
5       Thu Jun 30 05:39:57 +0000 2016        I like this movie5
6       Thu Jun 30 06:39:57 +0000 2016        I like this movie6
7       Thu Jun 30 06:29:57 +0000 2016        I like this movie6
8       Thu Jun 30 07:09:57 +0000 2016        I like this movie7
9       Thu Jun 30 07:39:57 +0000 2016        I like this movie8
10       Thu Jun 30 08:39:57 +0000 2016       I like this movie9
11      Thu Jun 30 09:39:57 +0000 2016        I like this movie10
12      Thu Jun 30 10:29:57 +0000 2016        I like this movie11
13      Thu Jun 30 11:29:57 +0000 2016        I like this movie12
12      Thu Jun 30 12:29:57 +0000 2016        I like this movie13

我想 select 按小时时间分隔的数据。 比如我要select小时小于等于06的所有数据,那么我要select小时大于07的数据。由于column的数据是datetime形式:Thu Jun 30 12:29:57 +0000 2016,我不知道该如何处理。感谢您的帮助!

sql 是 presto(presto sql):

select id, created, text from t1 where created_at <= 6

如果你使用的是 mssql,你可以为此使用 datepart:

select 
   id, 
   created, 
   text 
from 
   t1 
where 
   datepart(hour, created) <= 6

参考文献:

我搞定了,用小时(datestamp)就可以解决

select id, created, text from t1 where hour(created_at) <= 6