Specify the date to query the number of Oracle databases and specify the date to query the oracle database

Source: Internet
Author: User

Specify the date to query the number of Oracle databases and specify the date to query the oracle database

1. First, introduce the to_char function.

TO_CHAR converts a date or number to a string and cannot specify the string length.
Use the TO_CHAR function to process the date:
TO_CHAR (number, 'format') for example: TO_CHAR (salary, '$99,999.99 ')
Use the TO_CHAR function to process the date:
TO_CHAR (date, 'format'); TO_CHAR (newdate, 'yyyy-mm-dd') -- convert the specified date to year-month-day

TO_CHAR (newdate, 'yyyy-mm-dd hh24: mi: ssss') -- converts a specified date to year, month, day, hour, minute, and second.
 

 

2. You can use iPad or substring to operate the operating string in oracle.

The length of the specified string can be lpad, rpad, or substring:
Lpad (field name, fill length, fill character) left fill
Rpad (field name, fill length, fill character) Right fill
Substr (string, start_position, [length]) gets the string with the specified start position and length.

 

Next, we will query the data information of March December 5.

Select * from table_name t where to_char (t. column_name, 'yyyy-mm-dd') = '2017-12-05'

 

Query the first December 5 data records in 100.

Select * from (select * from table_name t where to_char (t. column_name, 'yyyy-mm-dd') = '2017-12-05 ') where rownum <= 2014

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.