str_to_date('2016-08-24', '%Y-%m-%d %H') validStartTime
str_to_date('2016-09-16', '%Y-%m-%d %H') validEndTime
--只有开始日期
select * from TimeTest t
where t.validStartTime >= str_to_date('2016-08-24', '%Y-%m-%d %H')
--只有结束日期
select * from TimeTest t
where t.validEndTime<str_to_date('2016-09-16', '%Y-%m-%d %H')
--开始日期,结束日期都有
select * from TimeTest t
where
t.validStartTime < str_to_date('2016-09-16', '%Y-%m-%d %H')
and t.validEndTime>=str_to_date('2016-08-24', '%Y-%m-%d %H')