Skip to content

Commit 029d22d

Browse files
committed
Update date-trunc.md
1 parent fcf6996 commit 029d22d

File tree

1 file changed

+14
-12
lines changed
  • docs/en/sql-reference/20-sql-functions/05-datetime-functions

1 file changed

+14
-12
lines changed
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
title: DATE_TRUNC
33
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.697"/>
47

58
Truncates a date, time, or timestamp value to a specified precision. For example, if you truncate `2022-07-07` to `MONTH`, the result will be `2022-07-01`; if you truncate `2022-07-07 01:01:01.123456` to `SECOND`, the result will be `2022-07-07 01:01:01.000000`.
69

@@ -9,25 +12,24 @@ Truncates a date, time, or timestamp value to a specified precision. For example
912
```sql
1013
DATE_TRUNC(<precision>, <date_or_time_expr>)
1114
```
12-
## Arguments
1315

14-
| Arguments | Description |
15-
|-----------------------|----------------------------------------------------------------------------------------------------|
16-
| `<precision>` | Must be of the following values: `YEAR`, `QUARTER`, `MONTH`, `DAY`, `HOUR`, `MINUTE` and `SECOND` |
17-
| `<date_or_time_expr>` | A value of `DATE` or `TIMESTAMP` type |
16+
| Parameter | Description |
17+
|-----------------------|------------------------------------------------------------------------------------------------------------|
18+
| `<precision>` | Must be of the following values: `YEAR`, `QUARTER`, `MONTH`, `WEEK`, `DAY`, `HOUR`, `MINUTE` and `SECOND`. |
19+
| `<date_or_time_expr>` | A value of `DATE` or `TIMESTAMP` type. |
1820

1921
## Return Type
2022

21-
The function returns a value of the same type as the `<date_or_time_expr>` argument.
23+
Same as `<date_or_time_expr>`.
2224

2325
## Examples
2426

2527
```sql
26-
select date_trunc(month, to_date('2022-07-07'));
28+
SELECT DATE_TRUNC(MONTH, to_date('2022-07-07')), DATE_TRUNC(WEEK, to_date('2022-07-07'));
2729

28-
┌──────────────────────────────────────────┐
29-
date_trunc(month, to_date('2022-07-07')) │
30-
├──────────────────────────────────────────┤
31-
2022-07-01
32-
└──────────────────────────────────────────┘
30+
┌────────────────────────────────────────────────────────────────────────────────────
31+
DATE_TRUNC(MONTH, to_date('2022-07-07')) │ DATE_TRUNC(WEEK, to_date('2022-07-07')) │
32+
├──────────────────────────────────────────┼─────────────────────────────────────────
33+
2022-07-01 2022-07-04
34+
└────────────────────────────────────────────────────────────────────────────────────
3335
```

0 commit comments

Comments
 (0)