Skip to content

Commit 51c65d9

Browse files
committed
Fix incorrect definition of to_char and add supported patterns
1 parent 16b47bc commit 51c65d9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

content/en/logs/workspaces/sql_reference.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ The following SQL functions are supported. For Window function, see the separate
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. |
9595
| `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. |
9696
| `to_timestamp(string timestamp, string format)` | timestamp | Converts a string to a timestamp according to the given format. |
97-
| `to_char(timestamp t / interval i / numeric n, format f)` | string | Converts a timestamp, interval, or numeric value to a string using a format.|
97+
| `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. |
9999
| `regexp_like(string s, pattern p)` | boolean | Evaluates if a string matches a regular expression pattern. |
100100

@@ -258,6 +258,25 @@ SELECT
258258
{{< /code-block >}}
259259

260260
### `TO_CHAR`
261+
262+
Supported patterns for date/time formatting:
263+
| Pattern | Description |
264+
| ----------- | ------------------------------------ |
265+
| `YYYY` | year (4 digits) |
266+
| `YY` | year (2 digits) |
267+
| `MM` | month number (01 - 12) |
268+
| `DD` | day of month (01 - 31) |
269+
| `HH24` | hour of day (00 - 23) |
270+
| `HH12` | hour of day (01 - 12) |
271+
| `HH` | hour of day (01 - 12) |
272+
| `MI` | minute (00 - 59) |
273+
| `SS` | second (00 - 59) |
274+
| `MS` | millisecond (000 - 999) |
275+
| `TZ` | time-zone abbreviation |
276+
| `OF` | time-zone offset from UTC |
277+
| `AM` / `am` | meridiem indicator (without periods) |
278+
| `PM` / `pm` | meridiem indicator (without periods) |
279+
261280
{{< code-block lang="sql" >}}
262281
SELECT
263282
to_char(order_date, 'MM-DD-YYYY') AS formatted_date

0 commit comments

Comments
 (0)