Oracle Date Time range query

Source: Internet
Author: User

Oracle Date-Time range query

Field: String type (char), Length: 10

1=1'2011-06-01'2011-07-05';


Between To_date (' 2011-06-01 ', ' yyyy-mm-dd ') and to_date (' 20110705 ', ' yyyymmdd ');

Field: String type (char), Length: 20

SELECT * from Testdatetime t WHERE1=1and T.usedate >='2011-06-01'and T.usedate <='2011-07-05'; SELECT* FROM Testdatetime t WHERE1=1and To_date (T.usedate,'YYYY-MM-DD HH24:MI:SS') between To_date ('2011-07-01 12:00:00','YYYY-MM-DD HH24:MI:SS') and To_date ('20110702 12:00:00','YYYYMMDD HH24:MI:SS') ;

Field: DateTime type (DATE)

SELECT * from Testdatetime t WHERE1=1and T.startdate >= to_date ('2011-07-01','YYYY-MM-DD') and T.startdate<= To_date ('2011-07-02','YYYY-MM-DD'); SELECT* FROM Testdatetime t WHERE1=1and t.startdate between To_date ('2011-07-01','YYYY-MM-DD') and To_date ('2011-07-02','YYYY-MM-DD');
SELECT * from Testdatetime t WHERE 1=1 and t.startdate = To_date (' 2011-07-01 12:00:00 ', ' yyyy-mm-dd HH24:MI:SS ');
SELECT * from Testdatetime t WHERE 1=1 and To_char (t.startdate, ' yyyy-mm-dd ') = ' 2011-07-01 ';
SELECT * from Testdatetime t WHERE 1=1 and To_char (t.startdate, ' yyyy-mm-dd ') >= ' 2011-07-01 ' and To_char (t.startdate, ' Y Yyy-mm-dd ') <= ' 2011-07-02 ';

Oracle Date Time range query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.