Update docs

This commit is contained in:
Robert Schulze 2023-11-02 20:51:43 +00:00
parent c6f826d929
commit 492af27feb
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A

View File

@ -1557,10 +1557,10 @@ Returns for a given date, the number of days passed since [1 January 0000](https
toDaysSinceYearZero(date[, time_zone])
```
Aliases: `TO_DAYS`
Alias: `TO_DAYS`
**Arguments**
- `date` — The date to calculate the number of days passed since year zero from. [Date](../../sql-reference/data-types/date.md), [Date32](../../sql-reference/data-types/date32.md), [DateTime](../../sql-reference/data-types/datetime.md) or [DateTime64](../../sql-reference/data-types/datetime64.md).
- `time_zone` — A String type const value or a expression represent the time zone. [String types](../../sql-reference/data-types/string.md)
@ -1584,11 +1584,15 @@ Result:
└────────────────────────────────────────────┘
```
## fromDaysSinceYearZero / fromDaysSinceYearZero32
**See Also**
Given the number of days passed since [1 January 0000](https://en.wikipedia.org/wiki/Year_zero) in the [proleptic Gregorian calendar defined by ISO 8601](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar) return a corresponding date (as Date type) . The calculation is the same as in MySQL's [`FROM_DAYS()`](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-days) function.
- [fromDaysSinceYearZero](#fromDaysSinceYearZero)
Overflow behaviour is configured by setting `date_time_overflow_behavior` to `ignore` (default), `saturate` (clamps) or `throw`.
## fromDaysSinceYearZero
Returns for a given number of days passed since [1 January 0000](https://en.wikipedia.org/wiki/Year_zero) the corresponding date in the [proleptic Gregorian calendar defined by ISO 8601](https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar). The calculation is the same as in MySQL's [`FROM_DAYS()`](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_from-days) function.
The overflow behaviour can be configured using setting `date_time_overflow_behavior` to `ignore` (default), `saturate` (clamps) or `throw`.
**Syntax**
@ -1596,29 +1600,39 @@ Overflow behaviour is configured by setting `date_time_overflow_behavior` to `ig
fromDaysSinceYearZero(days)
```
**Arguments**
- `days` — The number of days passed since year zero.
- `days` — The number of days passed since year zero.
**Returned value**
Date corresponding to the number of days passed since year zero.
The date corresponding to the number of days passed since year zero.
Type: [Date](../../sql-reference/data-types/date.md).
**Example**
``` sql
SET date_time_overflow_behavior = 'ignore';
SELECT fromDaysSinceYearZero(739136), fromDaysSinceYearZero32(693961), fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08')));
SELECT fromDaysSinceYearZero(739136), fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08')));
```
Result:
``` text
┌─fromDaysSinceYearZero(739136)─┬─fromDaysSinceYearZero32(693961)─┬─fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08')))─┐
│ 2023-09-08 │ 1900-01-01 │ 2023-09-08 │
└───────────────────────────────┴─────────────────────────────────┴──────────────────────────────────────────────────────────────────┘
┌─fromDaysSinceYearZero(739136)─┬─fromDaysSinceYearZero(toDaysSinceYearZero(toDate('2023-09-08')))─┐
│ 2023-09-08 │ 2023-09-08 │
└───────────────────────────────┴──────────────────────────────────────────────────────────────────┘
```
**See Also**
- [toDaysSinceYearZero](#toDaysSinceYearZero)
## fromDaysSinceYearZero32
Like [fromDaysSinceYearZero](#fromDaysSinceYearZero) but returns a [Date32](../../sql-reference/data-types/date32.md).
## age
Returns the `unit` component of the difference between `startdate` and `enddate`. The difference is calculated using a precision of 1 microsecond.