Skip to content

Commit 31ae809

Browse files
committed
Add supported types for extract
1 parent 07d3e15 commit 31ae809

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

content/en/logs/workspaces/sql_reference.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The following SQL functions are supported. For Window function, see the separate
9292
| `trim(string s)` | string | Removes leading and trailing whitespace from the string. |
9393
| `replace(string s, string from, string to)` | string | Replaces occurrences of a substring within a string with another substring. |
9494
| `substring(string s, int start, int length)` | string | Extracts a substring from a string, starting at a given position and for a specified length. |
95-
| `extract(field from timestamp/interval)` | numeric | Extracts a part of a date or time field (such as year or month) from a timestamp or interval. |
95+
| `extract(unit from timestamp/interval)` | numeric | Extracts a part of a date or time field (such as year or month) from a timestamp or interval. |
9696
| `to_timestamp(string timestamp, string format)` | timestamp | Converts a string to a timestamp according to the given format. |
9797
| `to_char(timestamp t, string format)` | string | Converts a timestamp to a string according to the given format. |
9898
| `date_trunc(string unit, timestamp t)` | timestamp | Truncates a timestamp to a specified precision based on the provided unit. |
@@ -232,6 +232,23 @@ FROM
232232
{{< /code-block >}}
233233

234234
### `EXTRACT`
235+
236+
Supported extraction units:
237+
| Literal | Input Type | Description |
238+
| ------------------| ------------------------ | -------------------------------------------- |
239+
| `day` | `timestamp` / `interval` | day of the month |
240+
| `dow` | `timestamp` | day of the week `1` (Monday) to `7` (Sunday) |
241+
| `doy` | `timestamp` | day of the year (`1` - `366`) |
242+
| `hour` | `timestamp` / `interval` | hour of the day (`0` - `23`) |
243+
| `minute` | `timestamp` / `interval` | minute of the hour (`0` - `59`) |
244+
| `second` | `timestamp` / `interval` | second of the minute (`0` - `59`) |
245+
| `week` | `timestamp` | week of the year (`1` - `53`) |
246+
| `month` | `timestamp` | month of the year (`1` - `12`) |
247+
| `quarter` | `timestamp` | quarter of the year (`1` - `4`) |
248+
| `year` | `timestamp` | year |
249+
| `timezone_hour` | `timestamp` | hour of the time-zone offfset |
250+
| `timezone_minute` | `timestamp` | minute of the time-zone offset |
251+
235252
{{< code-block lang="sql" >}}
236253
SELECT
237254
extract(year FROM purchase_date) AS purchase_year

0 commit comments

Comments
 (0)