How to Use the TRUNC Function in Excel - WindowsTips.net - Windows Tips and Tricks with Geek

Thursday, February 10, 2022

How to Use the TRUNC Function in Excel

 Excel Logo

How to Use the TRUNC Function

Let’s look at examples of the TRUNC function with some sample data. The below example uses the following TRUNC function.

=TRUNC(A2)

If you do not specify how many digits to truncate, all decimal places will be removed.

First TRUNC function example

You can see with the value in cell A2 that the TRUNC function does not apply any rounding. It simply truncates the number to 411.

Let’s see another example. This time we will reduce the values to two decimal places.

=TRUNC(A2,2)

TRUNC function to two decimal places

The TRUNC function will not display extra decimals if you ask it to show more than you have.

Take the following example, and let’s truncate it to two decimal places.

=TRUNC(A2,2)

No extra decimals shown by TRUNC

The value in cell A4 is reduced to two decimal places, but the values in A2 and A3 stay as they are because they have less than two decimal places already.

If you want to display the two decimals, the cells will need to be formatted to be forced to show them.

Remove the Time from a Date-Time Stamp

A useful example of TRUNC is to remove the time from a date and time stamp in Excel.

Imagine having the following date and time stamps, but we just want the date in a column for analysis.

Date and time sample data

The following formula will work to remove the time.

=TRUNC(A2)

Time removed from a date in Excel

Although the time is removed, the resulting cells will still need to be formatted as a date only.

Use TRUNC to Shorten Numbers

This is a rare technique, but it is worth knowing that the TRUNC function will also accept negative numbers for the digits argument. When you use a negative number, the formula truncates the numbers to the left of the decimal point. However, it does not change the number of digits. It will replace them with zeroes.

Let’s look at the following example.

=TRUNC(A2,-1)

Entering minus digits for the second argument

You can see in each example that zero was used to replace the number that was removed from the left of the decimal point.

No comments:

Post a Comment