Here are the examples of Oracle SQL queries to get data for a particular date.
Get Data from Oracle Table for a Particular Date
To get data from the Oracle table for a particular date:
select * from demo_orders where trunc(order_timestamp) = to_date('21may2019','ddmonyyyy');
NOTE: It is better to use Trunc() function while comparing dates in Oracle. In the above example, we used the Trunc() function for the table field only, but you can use both sides. Below are the examples:
Below is an example to get data for the current date:
select * from demo_orders where trunc(order_timestamp) = trunc(sysdate);
Below is an example to get data for a particular date range:
select * from demo_orders where trunc(order_timestamp) >= to_date('21may2019','ddmonyyyy') and trunc(order_timestamp) <= to_date('30jun2019','ddmonyyyy');
OR
select * from demo_orders where trunc(order_timestamp) betweento_date('21may2019','ddmonyyyy') and to_date('30jun2019','ddmonyyyy');
Leave a comment
You must login or register to add a new comment.