Oracle Database date range queryThere are two methods:To_charAndTo_date MethodNext, we will introduce this process through an instance. Suppose we want to query the data from to. 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 running result is: The data of can be displayed, but the data of cannot be displayed.
All conclusions can be drawn:
① If you want to display data of 2011-30, you can <to_date ('1970-05-31 ', 'yyyy-mm-dd') to display the data of-30.
② If you want to display data of 2011-30, you can <= to_date ('2017-05-30 23:59:59 123', 'yyyy-mm-dd hh24: mi: ss.
To_char:
Query the preceding two dates.
- select * from tablename where to_char(time,'yyyy-mm-dd')>='2011-05-02'
- and to_char(time,'yyyy-mm-dd')<='2011-05-30'
Query Result: Data of and can be displayed simultaneously.
Here are two implementation methods for Oracle Database date range query: The to_date method and the to_char method. I hope this introduction will be helpful to you!