提交 56b401cf 编写于 作者: V Vitaly Baranov

Add documentation for new datetime functions toStartOfInterval()

and toStartOfTenMinutes().
上级 23d70b2e
...@@ -66,9 +66,9 @@ Leap seconds are not accounted for. ...@@ -66,9 +66,9 @@ Leap seconds are not accounted for.
Converts a date with time to a unix timestamp. Converts a date with time to a unix timestamp.
## toMonday ## toStartOfYear
Rounds down a date or date with time to the nearest Monday. Rounds down a date or date with time to the first day of the year.
Returns the date. Returns the date.
## toStartOfISOYear ## toStartOfISOYear
...@@ -76,6 +76,12 @@ Returns the date. ...@@ -76,6 +76,12 @@ Returns the date.
Rounds down a date or date with time to the first day of ISO year. Rounds down a date or date with time to the first day of ISO year.
Returns the date. Returns the date.
## toStartOfQuarter
Rounds down a date or date with time to the first day of the quarter.
The first day of the quarter is either 1 January, 1 April, 1 July, or 1 October.
Returns the date.
## toStartOfMonth ## toStartOfMonth
Rounds down a date or date with time to the first day of the month. Rounds down a date or date with time to the first day of the month.
...@@ -84,16 +90,18 @@ Returns the date. ...@@ -84,16 +90,18 @@ Returns the date.
!!! attention !!! attention
The behavior of parsing incorrect dates is implementation specific. ClickHouse may return zero date, throw an exception or do "natural" overflow. The behavior of parsing incorrect dates is implementation specific. ClickHouse may return zero date, throw an exception or do "natural" overflow.
## toStartOfQuarter ## toMonday
Rounds down a date or date with time to the first day of the quarter. Rounds down a date or date with time to the nearest Monday.
The first day of the quarter is either 1 January, 1 April, 1 July, or 1 October.
Returns the date. Returns the date.
## toStartOfYear ## toStartOfDay
Rounds down a date or date with time to the first day of the year. Rounds down a date with time to the start of the day.
Returns the date.
## toStartOfHour
Rounds down a date with time to the start of the hour.
## toStartOfMinute ## toStartOfMinute
...@@ -103,19 +111,19 @@ Rounds down a date with time to the start of the minute. ...@@ -103,19 +111,19 @@ Rounds down a date with time to the start of the minute.
Rounds down a date with time to the start of the five-minute interval. Rounds down a date with time to the start of the five-minute interval.
## toStartOfTenMinutes
Rounds down a date with time to the start of the ten-minute interval.
## toStartOfFifteenMinutes ## toStartOfFifteenMinutes
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.
Note: If you need to round a date with time to any other number of seconds, minutes, or hours, you can convert it into a number by using the toUInt32 function, then round the number using intDiv and multiplication, and convert it back using the toDateTime function. ## toStartOfInterval(time_or_data, INTERVAL x unit [, time_zone])
This is a generalization of other functions named `toStartOf*`. For example,
## toStartOfHour `toStartOfInterval(t, INTERVAL 1 year)` returns the same as `toStartOfYear(t)`,
`toStartOfInterval(t, INTERVAL 1 month)` returns the same as `toStartOfMonth(t)`,
Rounds down a date with time to the start of the hour. `toStartOfInterval(t, INTERVAL 1 day)` returns the same as `toStartOfDay(t)`,
`toStartOfInterval(t, INTERVAL 15 minute)` returns the same as `toStartOfFifteenMinutes(t)` etc.
## toStartOfDay
Rounds down a date with time to the start of the day.
## toTime ## toTime
......
...@@ -43,8 +43,13 @@ SELECT ...@@ -43,8 +43,13 @@ SELECT
Переводит дату-с-временем в число типа UInt8, содержащее номер секунды в минуте (0-59). Переводит дату-с-временем в число типа UInt8, содержащее номер секунды в минуте (0-59).
Секунды координации не учитываются. Секунды координации не учитываются.
## toMonday ## toStartOfYear
Округляет дату или дату-с-временем вниз до ближайшего понедельника. Округляет дату или дату-с-временем вниз до первого дня года.
Возвращается дата.
## toStartOfQuarter
Округляет дату или дату-с-временем вниз до первого дня квартала.
Первый день квартала - это одно из 1 января, 1 апреля, 1 июля, 1 октября.
Возвращается дата. Возвращается дата.
## toStartOfMonth ## toStartOfMonth
...@@ -54,14 +59,15 @@ SELECT ...@@ -54,14 +59,15 @@ SELECT
!!! attention !!! attention
Возвращаемое значение для некорректных дат зависит от реализации. ClickHouse может вернуть нулевую дату, выбросить исключение, или выполнить "естественное" перетекание дат между месяцами. Возвращаемое значение для некорректных дат зависит от реализации. ClickHouse может вернуть нулевую дату, выбросить исключение, или выполнить "естественное" перетекание дат между месяцами.
## toStartOfQuarter ## toMonday
Округляет дату или дату-с-временем вниз до первого дня квартала. Округляет дату или дату-с-временем вниз до ближайшего понедельника.
Первый день квартала - это одно из 1 января, 1 апреля, 1 июля, 1 октября.
Возвращается дата. Возвращается дата.
## toStartOfYear ## toStartOfDay
Округляет дату или дату-с-временем вниз до первого дня года. Округляет дату-с-временем вниз до начала дня. Возвращается дата-с-временем.
Возвращается дата.
## toStartOfHour
Округляет дату-с-временем вниз до начала часа.
## toStartOfMinute ## toStartOfMinute
Округляет дату-с-временем вниз до начала минуты. Округляет дату-с-временем вниз до начала минуты.
...@@ -69,16 +75,18 @@ SELECT ...@@ -69,16 +75,18 @@ SELECT
## toStartOfFiveMinute ## toStartOfFiveMinute
Округляет дату-с-временем вниз до начала пятиминутного интервала. Округляет дату-с-временем вниз до начала пятиминутного интервала.
## toStartOfTenMinutes
Округляет дату-с-временем вниз до начала десятиминутного интервала.
## toStartOfFifteenMinutes ## toStartOfFifteenMinutes
Округляет дату-с-временем вниз до начала пятнадцатиминутного интервала. Округляет дату-с-временем вниз до начала пятнадцатиминутного интервала.
Замечание: если вам нужно округлить дату-с-временем до какого-либо другого количества секунд, минут или часов, вы можете перевести её в число с помощью функции toUInt32, затем округлить число с помощью функции intDiv и умножения, а затем перевести обратно, с помощью функции toDateTime. ## toStartOfInterval(time_or_data, INTERVAL x unit [, time_zone])
Обобщение остальных функций `toStartOf*`. Например,
## toStartOfHour `toStartOfInterval(t, INTERVAL 1 year)` возвращает то же самое, что и `toStartOfYear(t)`,
Округляет дату-с-временем вниз до начала часа. `toStartOfInterval(t, INTERVAL 1 month)` возвращает то же самое, что и `toStartOfMonth(t)`,
`toStartOfInterval(t, INTERVAL 1 day)` возвращает то же самое, что и `toStartOfDay(t)`,
## toStartOfDay `toStartOfInterval(t, INTERVAL 15 minute)` возвращает то же самое, что и `toStartOfFifteenMinutes(t)`, и т.п.
Округляет дату-с-временем вниз до начала дня.
## toTime ## toTime
Переводит дату-с-временем на некоторую фиксированную дату, сохраняя при этом время. Переводит дату-с-временем на некоторую фиксированную дату, сохраняя при этом время.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册