Truncates a number by removing decimal places.
TRUNC(number, places)
returns number with at most places decimal places. Excess decimal places are simply removed, irrespective of sign. TRUNC(number; 0) behaves as INT(number) for positive numbers, but effectively rounds towards zero for negative numbers.
TRUNC(1.239, 2)
returns 1.23. The 9 is lost.
TRUNC(-1.234999, 3)
returns -1.234. All the 9s are lost.
Let's consider an application for TRUNC in the context of inventory management for a retail store. Imagine a store that sells items in bulk, but sometimes they need to calculate how many full, complete packages they can create from a given amount of raw material.
Scenario: A pet store sells dog food in 5 kg bags. They receive a large shipment of dog food in a single bulk container and need to determine how many full bags they can fill.
Table: Bulk Inventory
Product ID | Product Name | Total Weight KG | Bag Size KG | ||
|---|---|---|---|---|---|
A | B | C | D | ||
1 | 101 | Dog Food | 234.7 | 5 | |
2 | 102 | Cat Food | 150.3 | 2 | |
3 | 103 | Bird Seed | 78.9 | 1 |
To find the number of full bags of dog food that can be created, we can use the TRUNC function. The calculation would be Total_Weight_KG / Bag_Size_KG. If we simply perform this division, we would get a number with a decimal, which represents the total number of bags including a partially filled one. However, the store is only interested in the number of complete bags.
Here's how the TRUNC function would be applied:
Product ID | Product Name | Total Weight KG | Bag Size KG | Full Bags Possible | ||
|---|---|---|---|---|---|---|
A | B | C | D | E | ||
1 | 101 | Dog Food | 234.7 | 5 | 46 | |
2 | 102 | Cat Food | 150.3 | 2 | 75 | |
3 | 103 | Bird Seed | 78.9 | 1 | 78 |
Explanation:
This example clearly demonstrates the practical use of TRUNC to get a whole number result by simply chopping off the decimal part, which is crucial for inventory calculations where partial units are not counted as "complete" items.
PRODUCT & FEATURES
RESOURCES
Terms | Privacy | Spam Policy
© 2026 Zapof