Skip to content

Commit d38943c

Browse files
committed
Add TRUNC
1 parent 45dcabb commit d38943c

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed
Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
11
---
2-
title: TRUNC in Azure Cosmos DB query language
3-
description: Learn about SQL system function TRUNC in Azure Cosmos DB.
4-
author: ginamr
2+
title: TRUNC
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns a truncated numeric value.
5+
author: jcodella
6+
ms.author: jacodel
7+
ms.reviewer: sidandrews
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.topic: conceptual
8-
ms.date: 06/22/2021
9-
ms.author: girobins
10-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/24/2023
12+
ms.custom: query-reference
1113
---
12-
# TRUNC (Azure Cosmos DB)
14+
15+
# TRUNC (NoSQL query)
16+
1317
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1418

15-
Returns a numeric value, truncated to the closest integer value.
16-
19+
Returns a numeric value truncated to the closest integer value.
20+
1721
## Syntax
18-
22+
1923
```sql
20-
TRUNC(<numeric_expr>)
21-
```
22-
24+
TRUNC(<numeric_expr>)
25+
```
26+
2327
## Arguments
24-
25-
*numeric_expr*
26-
Is a numeric expression.
27-
28+
29+
| | Description |
30+
| --- | --- |
31+
| **`numeric_expr`** | A numeric expression. |
32+
2833
## Return types
29-
30-
Returns a numeric expression.
31-
34+
35+
Returns a numeric expression.
36+
3237
## Examples
33-
34-
The following example truncates the following positive and negative numbers to the nearest integer value.
35-
36-
```sql
37-
SELECT TRUNC(2.4) AS t1, TRUNC(2.6) AS t2, TRUNC(2.5) AS t3, TRUNC(-2.4) AS t4, TRUNC(-2.6) AS t5
38-
```
39-
40-
Here is the result set.
41-
42-
```json
43-
[{t1: 2, t2: 2, t3: 2, t4: -2, t5: -2}]
44-
```
38+
39+
This example illustrates various ways to truncate a number to the closest integer.
40+
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/trunc/query.sql" highlight="2-6":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/trunc/result.json":::
4544

4645
## Remarks
4746

48-
This system function will benefit from a [range index](../../index-policy.md#includeexclude-strategy).
47+
- This unction benefits from a [range index](../../index-policy.md#includeexclude-strategy).
4948

5049
## Next steps
5150

5251
- [System functions Azure Cosmos DB](system-functions.yml)
53-
- [Introduction to Azure Cosmos DB](../../introduction.md)
52+
- [`TRIM`](trim.md)

0 commit comments

Comments
 (0)