mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #70488 from Blargian/docs_conversion_functions
[Docs] update `toFixedString` and `toISOWeek`
This commit is contained in:
commit
9bdbf30cf7
@ -2010,6 +2010,38 @@ Result:
|
||||
|
||||
Converts a date, or date with time, to a UInt8 number containing the ISO Week number.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toISOWeek(value)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `value` — The value with date or date with time.
|
||||
|
||||
**Returned value**
|
||||
|
||||
- `value` converted to the current ISO week number. [UInt8](../data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
toISOWeek(toDate('2024/10/02')) AS week1,
|
||||
toISOWeek(toDateTime('2024/10/02 01:30:00')) AS week2
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```response
|
||||
┌─week1─┬─week2─┐
|
||||
│ 40 │ 40 │
|
||||
└───────┴───────┘
|
||||
```
|
||||
|
||||
## toWeek
|
||||
|
||||
This function returns the week number for date or datetime. The two-argument form of `toWeek()` enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the default mode is 0.
|
||||
|
@ -5230,15 +5230,52 @@ Result:
|
||||
|
||||
Also see the `toUnixTimestamp` function.
|
||||
|
||||
## toFixedString(s, N)
|
||||
## toFixedString
|
||||
|
||||
Converts a [String](../data-types/string.md) type argument to a [FixedString(N)](../data-types/fixedstring.md) type (a string of fixed length N).
|
||||
If the string has fewer bytes than N, it is padded with null bytes to the right. If the string has more bytes than N, an exception is thrown.
|
||||
|
||||
## toStringCutToZero(s)
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toFixedString(s, N)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `s` — A String to convert to a fixed string. [String](../data-types/string.md).
|
||||
- `N` — Length N. [UInt8](../data-types/int-uint.md)
|
||||
|
||||
**Returned value**
|
||||
|
||||
- An N length fixed string of `s`. [FixedString](../data-types/fixedstring.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
``` sql
|
||||
SELECT toFixedString('foo', 8) AS s;
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌─s─────────────┬─s_cut─┐
|
||||
│ foo\0\0\0\0\0 │ foo │
|
||||
└───────────────┴───────┘
|
||||
```
|
||||
|
||||
## toStringCutToZero
|
||||
|
||||
Accepts a String or FixedString argument. Returns the String with the content truncated at the first zero byte found.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
toStringCutToZero(s)
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
Loading…
Reference in New Issue
Block a user