I had a query as below in my function. In that I need to filter based on the a.submit_date
SELECT mail_id , mail_async, mail_priority FROM glms_mail_sys_mail_store a
WHERE
--(TO_DATE(a.submit_date,'dd-MM-yyyy HH:mm') >= '14-06-2012 18:30')
--AND (TO_DATE(a.submit_date,'dd-MM-yyyy HH:mm') <= '15-06-2012 18:50')
(TO_DATE(TO_CHAR(a.submit_date,'dd-MM-yyyy HH:mm'),'dd-MM-yyyy HH:mm') >= '14-06-2012 18:30')
AND (TO_DATE(TO_CHAR(a.submit_date,'dd-MM-yyyy HH:mm'),'dd-MM-yyyy HH:mm') <= '15-06-2012 18:30')
In My DB a.submit_date had a value as ’14-06-2012 20:30′
But its throwing Invalid month… can anyone help to correct this?
First, try this below, it works:
Then, you need to convert the right side of the inequalities to dates.
If you want to write it a bit cleaner, use
BETWEENinstead:EDIT:
Here’s a complete example:
Output: