@@ -92,7 +92,7 @@ The following SQL functions are supported. For Window function, see the separate
92
92
| ` trim(string s) ` | string | Removes leading and trailing whitespace from the string. |
93
93
| ` replace(string s, string from, string to) ` | string | Replaces occurrences of a substring within a string with another substring. |
94
94
| ` 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. |
96
96
| ` to_timestamp(string timestamp, string format) ` | timestamp | Converts a string to a timestamp according to the given format. |
97
97
| ` to_char(timestamp t, string format) ` | string | Converts a timestamp to a string according to the given format. |
98
98
| ` date_trunc(string unit, timestamp t) ` | timestamp | Truncates a timestamp to a specified precision based on the provided unit. |
@@ -232,6 +232,23 @@ FROM
232
232
{{< /code-block >}}
233
233
234
234
### ` 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
+
235
252
{{< code-block lang="sql" >}}
236
253
SELECT
237
254
extract(year FROM purchase_date) AS purchase_year
0 commit comments