You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/operations/settings/settings.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4384,6 +4384,17 @@ Possible values:
4384
4384
4385
4385
Default value: `ignore`.
4386
4386
4387
+
## first_day_of_week
4388
+
4389
+
The first day of the week assumed by [`toStartOfInterval`](../../sql-reference/functions/date-time-functions.md#toStartOfInterval) function when using weeks as unit.
Enables or disables automatic [PREWHERE](../../sql-reference/statements/select/prewhere.md) optimization in [SELECT](../../sql-reference/statements/select/index.md) queries.
-`t` - a [Date](../data-types/date.md), [Date32](../data-types/date32.md), [DateTime](../data-types/datetime.md) or [DateTime64](../data-types/datetime64.md)
1055
-
-`mode` - determines the first day of the week as described in the [toWeek()](date-time-functions#toweek) function
1055
+
-`mode` - determines the first day of the week as described in the [toWeek()](date-time-functions#toweek) function. Default: 0
1056
1056
-`timezone` - Optional parameter, it behaves like any other conversion function
## toStartOfInterval(date_or_date_with_time, INTERVAL x unit \[, time_zone\])
1416
+
## toStartOfInterval
1417
1417
1418
1418
This function generalizes other `toStartOf*()` functions. For example,
1419
1419
-`toStartOfInterval(t, INTERVAL 1 year)` returns the same as `toStartOfYear(t)`,
@@ -1440,6 +1440,8 @@ The calculation is performed relative to specific points in time:
1440
1440
(*) hour intervals are special: the calculation is always performed relative to 00:00:00 (midnight) of the current day. As a result, only
1441
1441
hour values between 1 and 23 are useful.
1442
1442
1443
+
If unit `week` was specified, `toStartOfInterval` assumes by default that weeks start on Monday. You can change this behavior with setting [`first_day_of_week`](../../operations/settings/settings.md/#first-day-of-week)
1444
+
1443
1445
**See Also**
1444
1446
1445
1447
-[date_trunc](#date_trunc)
@@ -1673,7 +1675,7 @@ Like [fromDaysSinceYearZero](#fromDaysSinceYearZero) but returns a [Date32](../.
1673
1675
Returns the `unit` component of the difference between `startdate` and `enddate`. The difference is calculated using a precision of 1 nanosecond.
1674
1676
E.g. the difference between `2021-12-29` and `2022-01-01` is 3 days for `day` unit, 0 months for `month` unit, 0 years for `year` unit.
1675
1677
1676
-
For an alternative to `age`, see function `date\_diff`.
1678
+
For an alternative to `age`, see function `date_diff`.
1677
1679
1678
1680
**Syntax**
1679
1681
@@ -1747,9 +1749,9 @@ Result:
1747
1749
Returns the count of the specified `unit` boundaries crossed between the `startdate` and the `enddate`.
1748
1750
The difference is calculated using relative units, e.g. the difference between `2021-12-29` and `2022-01-01` is 3 days for unit `day` (see [toRelativeDayNum](#torelativedaynum)), 1 month for unit `month` (see [toRelativeMonthNum](#torelativemonthnum)) and 1 year for unit `year` (see [toRelativeYearNum](#torelativeyearnum)).
1749
1751
1750
-
If unit `week` was specified, `date\_diff` assumes that weeks start on Monday. Note that this behavior is different from that of function `toWeek()` in which weeks start by default on Sunday.
1752
+
If unit `week` was specified, `date_diff` assumes that weeks start on Monday. Note that this behavior is different from that of function `toWeek()` in which weeks start by default on Sunday.
1751
1753
1752
-
For an alternative to `date\_diff`, see function `age`.
1754
+
For an alternative to `date_diff`, see function `age`.
1753
1755
1754
1756
**Syntax**
1755
1757
@@ -2843,7 +2845,7 @@ Result:
2843
2845
2844
2846
## fromUnixTimestamp
2845
2847
2846
-
This function converts a Unix timestamp to a calendar date and a time of a day.
2848
+
This function converts a Unix timestamp to a calendar date and a time of a day.
Copy file name to clipboardExpand all lines: src/Core/Settings.h
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -549,6 +549,7 @@ class IColumn;
549
549
M(Bool, formatdatetime_parsedatetime_m_is_month_name, true, "Formatter '%M' in functions 'formatDateTime()' and 'parseDateTime()' print/parse the month name instead of minutes.", 0) \
550
550
M(Bool, parsedatetime_parse_without_leading_zeros, true, "Formatters '%c', '%l' and '%k' in function 'parseDateTime()' parse months and hours without leading zeros.", 0) \
551
551
M(Bool, formatdatetime_format_without_leading_zeros, false, "Formatters '%c', '%l' and '%k' in function 'formatDateTime()' print months and hours without leading zeros.", 0) \
552
+
M(FirstDayOfWeek, first_day_of_week, FirstDayOfWeek::Monday, "The first day of the week (Monday or Sunday) used by date/time functions (default: Monday).", 0) \
552
553
\
553
554
M(UInt64, max_partitions_per_insert_block, 100, "Limit maximum number of partitions in single INSERTed block. Zero means unlimited. Throw exception if the block contains too many partitions. This setting is a safety threshold, because using large number of partitions is a common misconception.", 0) \
554
555
M(Bool, throw_on_max_partitions_per_insert_block, true, "Used with max_partitions_per_insert_block. If true (default), an exception will be thrown when max_partitions_per_insert_block is reached. If false, details of the insert query reaching this limit with the number of partitions will be logged. This can be useful if you're trying to understand the impact on users when changing max_partitions_per_insert_block.", 0) \
Copy file name to clipboardExpand all lines: src/Core/SettingsChangesHistory.h
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,7 @@ static std::map<ClickHouseVersion, SettingsChangesHistory::SettingsChanges> sett
90
90
{"lightweight_deletes_sync", 2, 2, "The same as 'mutation_sync', but controls only execution of lightweight deletes"},
91
91
{"query_cache_system_table_handling", "save", "throw", "The query cache no longer caches results of queries against system tables"},
92
92
{"input_format_hive_text_allow_variable_number_of_columns", false, true, "Ignore extra columns in Hive Text input (if file has more columns than expected) and treat missing fields in Hive Text input as default values."},
93
+
{"first_day_of_week", "Monday", "Monday", "Added a setting for the first day of the week for date/time functions"},
93
94
}},
94
95
{"24.3", {{"s3_connect_timeout_ms", 1000, 1000, "Introduce new dedicated setting for s3 connection timeout"},
95
96
{"allow_experimental_shared_merge_tree", false, true, "The setting is obsolete"},
0 commit comments