2015 first blog, Oracle time period query, comparison of TO_DATE and TO_CHAR, to_dateto_char

Source: Internet
Author: User

2015 first blog, Oracle time period query, comparison of TO_DATE and TO_CHAR, to_dateto_char
Preface:
During time period query, when TO_DATE is used, including the start date, not the end date;
When TO_CHAR is used, the start date or end date can be included. Effect


1. TO_DATE is used and no end date is found.



2. Use TO_CHAR to query the end date.



3. SQL comparison

-- Includes the start date, excluding the end date SELECT * from1__logwhere (OPERATE_TIME> TO_DATE ('2017-02-03 ', 'yyyy-mm-dd ') AND OPERATE_TIME <TO_DATE ('1970-02-06 ', 'yyyy-mm-dd') ORDER BYOPERATE_TIME DESC; -- including the start date AND end date SELECT * from1__logwhereto_char (OPERATE_TIME, 'yyyy-mm-dd')> = '2017-02-03 'AND TO_CHAR (OPERATE_TIME, 'yyyy-mm-dd') <= '2017-02-06' ORDER BYOPERATE_TIME DESC;


Related Article

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.