Update date-time-functions.md

This commit is contained in:
Nikita Mikhaylov 2020-12-08 18:32:55 +03:00 committed by GitHub
parent a8616ea262
commit 767d1fc98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -693,14 +693,14 @@ SELECT FROM_UNIXTIME(1234334543, '%Y-%m-%d %R:%S') AS DateTime
└─────────────────────┘ └─────────────────────┘
``` ```
## toMJD {#tomjd} ## toModifiedJulianDay {#tomodifiedjulianday}
Converts a [Proleptic Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) date in text form `YYYY-MM-DD` to a [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) number in Int32. This function supports date from `0000-01-01` to `9999-12-31`. It raises an exception if the argument cannot be parsed as a date, or the date is invalid. Converts a [Proleptic Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) date in text form `YYYY-MM-DD` to a [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) number in Int32. This function supports date from `0000-01-01` to `9999-12-31`. It raises an exception if the argument cannot be parsed as a date, or the date is invalid.
**Syntax** **Syntax**
``` sql ``` sql
toMJD(date) toModifiedJulianDay(date)
``` ```
**Parameters** **Parameters**
@ -718,25 +718,25 @@ Type: [Int32](../../sql-reference/data-types/int-uint.md).
Query: Query:
``` sql ``` sql
SELECT toMJD('2020-01-01'); SELECT toModifiedJulianDay('2020-01-01');
``` ```
Result: Result:
``` text ``` text
┌─toMJD('2020-01-01')─┐ ┌─toModifiedJulianDay('2020-01-01')─┐
│ 58849 │ 58849 │
└─────────────────────┘ └───────────────────────────────────
``` ```
## toMJDOrNull {#tomjdornull} ## toModifiedJulianDayOrNull {#tomodifiedjuliandayornull}
Similar to [toMJD()](#tomjd), but instead of raising exceptions it returns `NULL`. Similar to [toModifiedJulianDay()](#tomodifiedjulianday), but instead of raising exceptions it returns `NULL`.
**Syntax** **Syntax**
``` sql ``` sql
toMJDOrNull(date) toModifiedJulianDayOrNull(date)
``` ```
**Parameters** **Parameters**
@ -754,25 +754,25 @@ Type: [Nullable(Int32)](../../sql-reference/data-types/int-uint.md).
Query: Query:
``` sql ``` sql
SELECT toMJDOrNull('2020-01-01'); SELECT toModifiedJulianDayOrNull('2020-01-01');
``` ```
Result: Result:
``` text ``` text
┌─toMJDOrNull('2020-01-01')─┐ ┌─toModifiedJulianDayOrNull('2020-01-01')─┐
│ 58849 │ 58849 │
└───────────────────────────┘ └─────────────────────────────────────────
``` ```
## fromMJD {#frommjd} ## fromModifiedJulianDay {#frommodifiedjulianday}
Converts a [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) number to a [Proleptic Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) date in text form `YYYY-MM-DD`. This function supports day number from `-678941` to `2973119` (which represent 0000-01-01 and 9999-12-31 respectively). It raises an exception if the day number is outside of the supported range. Converts a [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day#Variants) number to a [Proleptic Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) date in text form `YYYY-MM-DD`. This function supports day number from `-678941` to `2973119` (which represent 0000-01-01 and 9999-12-31 respectively). It raises an exception if the day number is outside of the supported range.
**Syntax** **Syntax**
``` sql ``` sql
fromMJD(day) fromModifiedJulianDay(day)
``` ```
**Parameters** **Parameters**
@ -790,25 +790,25 @@ Type: [String](../../sql-reference/data-types/string.md)
Query: Query:
``` sql ``` sql
SELECT fromMJD(58849); SELECT fromModifiedJulianDay(58849);
``` ```
Result: Result:
``` text ``` text
┌─fromMJD(58849)─┐ ┌─fromModifiedJulianDay(58849)─┐
│ 2020-01-01 │ │ 2020-01-01
└────────────────┘ └──────────────────────────────
``` ```
## fromMJDOrNull {#frommjdornull} ## fromModifiedJulianDayOrNull {#frommodifiedjuliandayornull}
Similar to [fromMJD()](#frommjd), but instead of raising exceptions it returns `NULL`. Similar to [fromModifiedJulianDayOrNull()](#frommodifiedjuliandayornull), but instead of raising exceptions it returns `NULL`.
**Syntax** **Syntax**
``` sql ``` sql
fromMJDOrNull(day) fromModifiedJulianDayOrNull(day)
``` ```
**Parameters** **Parameters**
@ -826,13 +826,13 @@ Type: [Nullable(String)](../../sql-reference/data-types/string.md)
Query: Query:
``` sql ``` sql
SELECT fromMJDOrNull(58849); SELECT fromModifiedJulianDayOrNull(58849);
``` ```
Result: Result:
``` text ``` text
┌─fromMJDOrNull(58849)─┐ ┌─fromModifiedJulianDayOrNull(58849)─┐
│ 2020-01-01 │ │ 2020-01-01
└──────────────────────┘ └────────────────────────────────────
``` ```