DB version: 11gR2
Is there a shorter way to find all orders placed on the month of June 2015 ? ie something shorter than the below mentioned one
create table orders (product varchar2(35), order_date date);
insert into orders VALUES ('APPLE' , TO_DATE('07-JUN-2015 21:00','DD-MON-YYYY HH24:MI')) ;
insert into orders VALUES ('ORANGE' , TO_DATE('07-JUN-2015 08:30','DD-MON-YYYY HH24:MI')) ;
insert into orders VALUES ('AVOCADO' , TO_DATE('21-SEP-2012 19:30','DD-MON-YYYY HH24:MI')) ;
SQL> alter session set nls_date_format='DD-MM-YYYY HH24:MI';
Session altered.
SQL> select * from orders;
PRODUCT ORDER_DATE
----------------------------------- ----------------
APPLE 07-06-2015 21:00
ORANGE 07-06-2015 08:30
AVOCADO 21-09-2012 19:30
-- Retrieving all orders placed on the month of June 2015
SQL> Select * from orders where order_date >= TO_DATE('01-JUN-2015 00:00','DD-MON-YYYY HH24:MI')
2 and
3 order_date < TO_DATE('30-JUN-2015 23:59','DD-MON-YYYY HH24:MI');
PRODUCT ORDER_DATE
----------------------------------- ----------------
APPLE 07-06-2015 21:00
ORANGE 07-06-2015 08:30