Difference between SQL Server and oracle in conditional query of datetime

Source: Internet
Author: User

First, let's take a look at SQL server. Previously, we used the foreground to select a start time and an end time (in the smallest unit of day), and then used it as a condition for query, if we use "between starttime and endtime" as the condition, we will automatically convert "" to "00:00:00 ", therefore, the following query condition is "between '2014-06-16 'and '2014-06-17'". Only data on the 16th day can be obtained. Data on the 17th day cannot be obtained, if you want to check the data on the 17th day, you can process the selected time: You can add detailed time conditions for it, for example, "between '2017-06-16 00:00:00 'and '2017-06-17 23:59:59'", or simply replace the end time with the date of the next day, however, we need to make a special processing on the incremental date, because we may encounter the situation of choosing the last day of the month, detailed I will not go into details here.


Let's talk about the processing in the oracle database, which is the same as the above two methods. But if we adopt the precise time method, we need to use the oracle database time function for processing, which is relatively cumbersome, it may be more convenient to directly increase the end date. Of course, the minimum unit of the selected date is "day. It should be noted that the date string format adopted in oracle is different from that of SQL server, generally in the format of "5-6-09, this requires an intermediate conversion of the obtained time format. Otherwise, the statement cannot be executed normally. Of course, we can also use database functions for processing, but it is relatively complicated.


In fact, sometimes we can take a more formal approach to deal with many problems. However, if there are some limitations within the scope of requirements, but the implementation method that can fully meet the needs, I think it can be used in a bold region, because the ultimate goal of our programming is: to achieve the goal in the simplest way, everything cannot be too rigid. This process is actually to improve our understanding of the project requirements. Finally, we need to pay attention to some of the issues that we must avoid when copying paths. Never be too careless.

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.