- Create table
1
2
3
4
create table MESSAGE_STORE(
message varchar2(200)
whenreceived date
);
- Oracle select record within a range using operator and date time
1
2
3
4
5
SELECT WHENRECEIVED,MESSAGE FROM MESSAGE_STORE
WHERE
WHENRECEIVED > TO_DATE('2012-01-15 18:04:21', 'YYYY-MM-DD HH24:MI:SS')
AND WHENRECEIVED < TO_DATE('2012-01-16 18:10:21', 'YYYY-MM-DD HH24:MI:SS')
ORDER BY WHENRECEIVED desc;
- Oracle select record within a range using between and date time
1
2
3
4
5
6
SELECT WHENRECEIVED,MESSAGE FROM MESSAGE_STORE
WHERE
WHENRECEIVED between TO_DATE('2012-01-15 18:04:21', 'YYYY-MM-DD HH24:MI:SS')
AND TO_DATE('2012-01-16 18:10:21', 'YYYY-MM-DD HH24:MI:SS')
ORDER BY WHENRECEIVED desc;