mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Update docs
This commit is contained in:
parent
f596ae7a2c
commit
ea2ba82c10
@ -1345,7 +1345,7 @@ toStartOfTenMinutes(toDateTime('2023-04-21 10:23:00')): 2023-04-21 10:20:00
|
|||||||
|
|
||||||
Rounds down the date with time to the start of the fifteen-minute interval.
|
Rounds down the date with time to the start of the fifteen-minute interval.
|
||||||
|
|
||||||
## toStartOfInterval(date_or_date_with_time, INTERVAL x unit \[, origin_time_or_data\] \[, time_zone\])
|
## toStartOfInterval
|
||||||
|
|
||||||
This function generalizes other `toStartOf*()` functions. For example,
|
This function generalizes other `toStartOf*()` functions. For example,
|
||||||
- `toStartOfInterval(t, INTERVAL 1 year)` returns the same as `toStartOfYear(t)`,
|
- `toStartOfInterval(t, INTERVAL 1 year)` returns the same as `toStartOfYear(t)`,
|
||||||
@ -1372,21 +1372,21 @@ The calculation is performed relative to specific points in time:
|
|||||||
(*) hour intervals are special: the calculation is always performed relative to 00:00:00 (midnight) of the current day. As a result, only
|
(*) hour intervals are special: the calculation is always performed relative to 00:00:00 (midnight) of the current day. As a result, only
|
||||||
hour values between 1 and 23 are useful.
|
hour values between 1 and 23 are useful.
|
||||||
|
|
||||||
Also it has an overload including `origin_time_or_data` column which emulates TimescaleDB's `time_bucket()` function, respectively PostgreSQL's `date_bin()` function:
|
**Syntax**
|
||||||
``` SQL
|
|
||||||
SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), toIntervalMinute(1), toDateTime('2023-01-01 14:35:30'));
|
```sql
|
||||||
|
toStartOfInterval(value, INTERVAL x unit[, time_zone])
|
||||||
|
toStartOfInterval(value, INTERVAL x unit[, origin[, time_zone]])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The second overload emulates TimescaleDB's `time_bucket()` function, respectively PostgreSQL's `date_bin()` function, e.g.
|
||||||
|
|
||||||
|
``` SQL
|
||||||
|
SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), INTERVAL 1 MINUTE, toDateTime('2023-01-01 14:35:30'));
|
||||||
|
```
|
||||||
**See Also**
|
**See Also**
|
||||||
|
|
||||||
|
|
||||||
- [date_trunc](#date_trunc)
|
- [date_trunc](#date_trunc)
|
||||||
|
|
||||||
Also it has an overload including `origin_time_or_data` column which emulates TimescaleDB's `time_bucket()` function, respectively PostgreSQL's `date_bin()` function:
|
|
||||||
``` SQL
|
|
||||||
SELECT toStartOfInterval(toDateTime('2023-01-01 14:45:00'), toIntervalMinute(1), toDateTime('2023-01-01 14:35:30'));
|
|
||||||
```
|
|
||||||
|
|
||||||
## toTime
|
## toTime
|
||||||
|
|
||||||
Converts a date with time to a certain fixed date, while preserving the time.
|
Converts a date with time to a certain fixed date, while preserving the time.
|
||||||
@ -2462,19 +2462,29 @@ SELECT
|
|||||||
└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘
|
└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## timeSlots(StartTime, Duration,\[, Size\])
|
## timeSlots
|
||||||
|
|
||||||
For a time interval starting at ‘StartTime’ and continuing for ‘Duration’ seconds, it returns an array of moments in time, consisting of points from this interval rounded down to the ‘Size’ in seconds. ‘Size’ is an optional parameter set to 1800 (30 minutes) by default.
|
For a time interval starting at ‘StartTime’ and continuing for ‘Duration’ seconds, it returns an array of moments in time, consisting of points from this interval rounded down to the ‘Size’ in seconds. ‘Size’ is an optional parameter set to 1800 (30 minutes) by default.
|
||||||
This is necessary, for example, when searching for pageviews in the corresponding session.
|
This is necessary, for example, when searching for pageviews in the corresponding session.
|
||||||
Accepts DateTime and DateTime64 as ’StartTime’ argument. For DateTime, ’Duration’ and ’Size’ arguments must be `UInt32`. For ’DateTime64’ they must be `Decimal64`.
|
Accepts DateTime and DateTime64 as ’StartTime’ argument. For DateTime, ’Duration’ and ’Size’ arguments must be `UInt32`. For ’DateTime64’ they must be `Decimal64`.
|
||||||
Returns an array of DateTime/DateTime64 (return type matches the type of ’StartTime’). For DateTime64, the return value's scale can differ from the scale of ’StartTime’ --- the highest scale among all given arguments is taken.
|
Returns an array of DateTime/DateTime64 (return type matches the type of ’StartTime’). For DateTime64, the return value's scale can differ from the scale of ’StartTime’ --- the highest scale among all given arguments is taken.
|
||||||
|
|
||||||
Example:
|
**Syntax**
|
||||||
|
|
||||||
|
```sql
|
||||||
|
timeSlots(StartTime, Duration,\[, Size\])
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600));
|
SELECT timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600));
|
||||||
SELECT timeSlots(toDateTime('1980-12-12 21:01:02', 'UTC'), toUInt32(600), 299);
|
SELECT timeSlots(toDateTime('1980-12-12 21:01:02', 'UTC'), toUInt32(600), 299);
|
||||||
SELECT timeSlots(toDateTime64('1980-12-12 21:01:02.1234', 4, 'UTC'), toDecimal64(600.1, 1), toDecimal64(299, 0));
|
SELECT timeSlots(toDateTime64('1980-12-12 21:01:02.1234', 4, 'UTC'), toDecimal64(600.1, 1), toDecimal64(299, 0));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
``` text
|
``` text
|
||||||
┌─timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600))─┐
|
┌─timeSlots(toDateTime('2012-01-01 12:20:00'), toUInt32(600))─┐
|
||||||
│ ['2012-01-01 12:00:00','2012-01-01 12:30:00'] │
|
│ ['2012-01-01 12:00:00','2012-01-01 12:30:00'] │
|
||||||
|
Loading…
Reference in New Issue
Block a user