create_date timestamp(6) without time zone
1.从2015-10-12到2015-10-13 之间的4点到9点的数据
select * from schedule where create_date
between to_date('2015-10-12','yyyy-MM-dd')
and to_date('2015-10-13','yyyy-MM-dd')
and EXTRACT(hour from create_date) between 4 and 9;
结果:
2.2015-10-12五点的数据
select * from schedule where hospital_id='syzyyadmin' and date_trunc('hour',create_date)=to_timestamp('2015-10-12 05','YYYY-MM-DD HH24')
结果: