Oracle functions integrate small example date operations

Source: Internet
Author: User
Tags string to number

Oracle Function Synthesis small example date operation premise there is a student table student contains a birthday field (Date Field) let you find a student over 10 years old. Here, we only use the year to judge the difference between the birthday and the current date. First, we need to convert the date type into a string, to_char (obj, formart) to_char (birthday, 'yyyymmdd') is converted into to_date (str, formart) to_date (sysdate, 'yyyy-mm-dd ') obtain the year substr (str, start index, truncation length) substr (to_char (birthday, 'yyyymmdd )) convert string to number to_number function to number to_number (substr (to_char (birthday, 'yyyymmdd ))) final sqlselect * from student where birthday is not null and (to_number (substr (to_char (sysdate, 'yyyymmdd'),)-to_number (substr (to_char (birthday, 'yyyymmdd'), 0, 4)> 10

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.