Skip to main content

TRUNC

Returns the integer part of a number by rounding towards zero, stripping away any fractional component.

See also:
[SELECT]


Syntax

SELECT TRUNC(numeric_expression) FROM <multipartIdentifier>;

Arguments

numeric_expression
An expression of the exact numeric or approximate numeric data type category.

Return Value(s)

Returns a numeric value truncated to its integer component.


Examples

Truncate the number of days since creation of Google Cloud Storage buckets to two decimal places

SELECT name, timeCreated,
TRUNC(julianday('now') - julianday(timeCreated)) as days_since
FROM google.storage.buckets WHERE project = 'stackql';