mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Update timeslot function
This commit is contained in:
parent
a985721129
commit
2218347180
@ -2413,6 +2413,47 @@ The same as ‘today() - 1’.
|
||||
|
||||
Rounds the time to the half hour.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
timeSlot(time)
|
||||
```
|
||||
**Parameters**
|
||||
|
||||
- `time`: Date and Time for which to round to the half hour. [Date](../data-types/date.md), [DateTime](../data-types/datetime.md), [Date32](../data-types/date32.md), [DateTime64](../data-types/datetime64.md).
|
||||
|
||||
:::note
|
||||
Though this function can take values of the extended types `Date32` and `DateTime64` as an argument, passing a time outside the normal range (year `1970` to `2149` for `Date` / `2106` for `DateTime`) will produce wrong results.
|
||||
:::
|
||||
|
||||
**Returned value**
|
||||
|
||||
:::note
|
||||
The return type of `timeslot` is determined by the configuration parameter [enable_extended_results_for_datetime_functions](../../operations/settings/settings.md#enable-extended-results-for-datetime-functions) which is `0` by default.
|
||||
|
||||
For:
|
||||
- `enable_extended_results_for_datetime_functions = 0` the return type is `DateTime`.
|
||||
- `enable_extended_results_for_datetime_functions = 1` the return type is `DateTime` if the argument type is a `Date` or `DateTime`, and returns `DateTime64` if the argument type is a `Date32` or `DateTime64`.
|
||||
:::
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC'));
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌─timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC'))─┐
|
||||
│ 2000-01-02 03:00:00 │
|
||||
└────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
|
||||
|
||||
## toYYYYMM
|
||||
|
||||
Converts a date or date with time to a UInt32 number containing the year and month number (YYYY \* 100 + MM). Accepts a second optional timezone argument. If provided, the timezone must be a string constant.
|
||||
|
Loading…
Reference in New Issue
Block a user