Oracle Time query

Source: Internet
Author: User

The Oracle query date can use =, but the data types must be consistent on both sides of the equal sign,

For example, '2014-9-19 'is a string that cannot be directly compared with a date field and must undergo date conversion:

Convert date to string to_char (date, 'yyyy-mm-dd') = '2017-09-19'

Convert a string to the date to_date ('1970-9-19 ', 'yyyy-mm-dd') = trunc (date) date may contain time, minute, and second. Note that

1. query the time value of a time field.

Select count (*) from t_date_table where to_char (c_time, 'yyyy-mm-dd') = '2017-03-28 ';

2. query the statistical value within a certain time range

Select count (*) from t_date_table where c_timee between to_date ('2017-03-26 ', 'yyyy-MM-DD') and to_date ('2017-03-28 ', 'yyyy-MM-DD ');

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.