Trunc function and months_between Function

Source: Internet
Author: User
Tags float number

Atof (converts a string to a float number)
Atoi (convert a string to an integer)
Atol (convert string to integer)
Gcvt (convert the float number to a string and rounding it out)
Strtodd (convert a string to a floating point number)

Select nvl (trunc (months_between (to_date (: splyendtm, 'yyyy-mm-dd hh24: MI: ss'), to_date (: sregtm, 'yyyy-mm ')), 1), '') into: smonthregend from dual;

 

Trunc function for truncation of values:
Trunc (number) indicates the truncation number, and trunc (date) indicates the truncation date.
(1) truncation number: Format: trunc (N1, N2)
N1 indicates the number to be truncated, N2 indicates the number to be truncated. N2 can be a negative number, indicating that the decimal point is truncated.
Note that trunc truncation is not rounding.

(2) truncation Date:
Run the command: Alter session set nls_date_format = 'yyyy-mm-dd hh24: MI: hh ';
Today's screenshot:
SQL> select sysdate, trunc (sysdate, 'dd') from dual;

Sysdate trunc (sysdate, 'dd ')
--------------------------------------
21:31:17 00:00:00

Months_between function:
Months_between (X, Y) is used to calculate the number of months between x and y.

If X is earlier than Y in the calendar, months_between () returns a negative number.

 

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.