Oracle built-in functions nvl, trunc

Source: Internet
Author: User

Nvl (string1, replace_with)

Function: If string1 is null, The nvl function returns the value of replace_with; otherwise, the value of string1 is returned.

This nvl serves the same purpose as isnull (string1, replace_with) in sqlserver.

Note: string1 and replace_with must be of the same data type unless the to_char function is displayed.

For example, nvl (field name, 0) indicates that when you select this field, although it is empty, it displays 0. Of course, this field can be changed to other items, such: 1, 2, 3 ......

 

 

TruncIs an oracle built-in function, you canDateType data is tailored to meet different types of data requirements.

Different format signs can be used to indicate different truncation locations and obtain various zero-moment time values.

 

 

Format String

Description

Year

Yyyy or year

First day of the year (, January 1, January 1)

Month

Mm or month

The first day of the month (zero hour per day)

Day

Dd Or day

Zero date (00:00:00)

Hours

HH or hh24

Total time (XX: 00: 00)

Minute

Mi

Fraction (XX: 00)

 

 

 

 

 

 

 

 

Quarterly Q

Zhou ww

 

 

// Truncation to Year

SQL> select trunc (sysdate, 'yyyy') from dual;

 

Trunc (sysdate, 'yyyy ')

---------------------

2010-1-1

// Truncate to month

SQL> select trunc (sysdate, 'mm') from dual;

 

Trunc (sysdate, 'mm ')

-------------------

2010-12-1

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.