I am trying to write an SQL statement that would allow me to retrieve all the orders created in the month of September without much luck.
Not working:
select order_number, created_date
from orders
where created_date in to_date('2012-09', 'YYYY-MM');
Working but too long:
select order_number, created_date
from orders
where trunc(created_date) between to_date('2012-09-01', 'YYYY-MM-DD') and to_date('2012-09-30', 'YYYY-MM-DD');
How about:
You should try to leave
created_dateuntouched to make sure that you can leverage indexes on it nicely.