Use of Oracletrunc () function

Source: Internet
Author: User

Use of Oracletrunc () function

-- Oracle trunc () function usage

/************** Date TRUNC () the function does not have second precision *******************/select sysdate from dual -- select trunc (sysdate) from dualselect trunc (sysdate, 'dd') from dual -- today's date select trunc (sysdate, 'D') + 7 from dual -- select trunc (sysdate, 'dy ') on Sunday of this week ') + 7 from dual -- select trunc (sysdate, 'day') + 7 from dual -- select trunc (sysdate, 'q') on Sunday of this week ') from dual -- select trunc (sysdate, 'month') from dual -- select trunc (sysdate, 'mm ') from dual -- select trunc (sysdate, 'Year') from dual -- select trunc (sysdate, 'yyyy ') from dual -- select trunc (sysdate, 'hh24') from dual -- select trunc (sysdate, 'mi ') from dual -- select trunc (sysdate, 'cc') from dual -- select trunc (LAST_DAY (sysdate), 'dd') from dual -- the last day of the month

The round (10.2356, 2) function rounds the number by the specified reserved decimal places. This function can also round the date.

Select round (sysdate, 'yyyy') from dual rounding to select round (sysdate, 'mm') from dual rounding to select round (sysdate, 'dd ') from dual rounding to daily select round (sysdate, 'hh ') from dual rounding to hour select round (sysdate, 'mi ') from dual rounded to minute ****************** ** // * TRUNC (number, num_digits) Number. Num_digits is used to specify the number to take an integer. The default value of Num_digits is 0. When TRUNC () function is truncated, No rounding is performed */select trunc (123.458) from dual -- 123 select trunc (123.458, 0) from dual -- 123 select trunc (123.458, 1) from dual -- 123.4 select trunc (123.458,-1) from dual -- 120 select trunc (123.458,-4) from dual -- 0 select trunc (123.458, 4) from dual -- 123.458 select trunc (123) from dual -- 123 select trunc (123) from dual -- 123 select trunc (120,-1) from dual --

 

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.