tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment

Other Sites

CheckYourMath BigActivities DigMinecraft
Share this page:

Oracle/PLSQL: TRUNC Function (with numbers)

Learn how to use the Oracle/PLSQL TRUNC function (as it applies to numeric values) with syntax and examples.

Description

The Oracle/PLSQL TRUNC function returns a number truncated to a certain number of decimal places.

Syntax (with numbers)

The syntax for the Oracle/PLSQL TRUNC function is:

TRUNC( number, [ decimal_places ] )

Parameters or Arguments

number is the number to truncate.

decimal_places is the number of decimal places to truncate to. This value must be an integer. If this parameter is omitted, the TRUNC function will truncate the number to 0 decimal places.

Applies To

The TRUNC function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example (with numbers)

Let's look at some Oracle TRUNC function examples and explore how to use the TRUNC function in Oracle/PLSQL.

For example:

TRUNC(125.815) would return 125
TRUNC(125.815, 0) would return 125
TRUNC(125.815, 1) would return 125.8
TRUNC(125.815, 2) would return 125.81
TRUNC(125.815, 3) would return 125.815
TRUNC(-125.815, 2) would return -125.81
TRUNC(125.815, -1) would return 120
TRUNC(125.815, -2) would return 100
TRUNC(125.815, -3) would return 0