Oracle’s method for querying date range is:
There are two ways to query date range in Oracle database: to_char method and to_date method, next We introduce this process through an example. We assume that we want to query the data between 2011-05-02 and 2011-05-30. The implementation method is as follows:
to_date method:
select * from tablename where time>= to_date('2011-05-02','yyyy-mm-dd') and time<=to_date('2011-05-30','yyyy-mm-dd')
The result of the operation is: 05-02 can be displayed data, but the data from 05-30 cannot be displayed.
All can be concluded:
①If you want to display the data from 05-30, you can ②If you want to display the data from 05-30, you can also use <=to_date('2011-05-30 23:59:59 999','yyyy-mm-dd hh24:mi:ss') It can be found out. to_char method: Similarly query the above two dates Query results: The data of 05-02 and 05-30 can be displayed at the same time. That’s all the relevant knowledge about the two implementation methods of Oracle database date range query: to_date method and to_char method. I hope this introduction can be helpful to you! Recommended tutorial: "Oracle Tutorial" The above is the detailed content of How to query date range in oracle. For more information, please follow other related articles on the PHP Chinese website!select * from tablename where to_char(time,'yyyy-mm-dd')>='2011-05-02'
and to_char(time,'yyyy-mm-dd')<='2011-05-30'