Wednesday, April 24, 2019

Oracle: using DATE type in the WHERE clause condition


If the WHERE clause contains a condition of DATE type, we can use TO_DATE() to convert a date string into DATE type. For example:

SELECT * FROM MyTable WHERE DateField > TO_DATE('2019-04-23 21:30:00', 'YYYY-MM-DD HH24:MI:SS');

The second parameter of TO_DATE() method is the format model. To find out the complete list of datetime format elements, follow this link: https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements004.htm#CDEHIFJA


No comments:

 
Get This <