zclllyybb commented on code in PR #998: URL: https://github.com/apache/doris-website/pull/998#discussion_r1716281158
########## docs/sql-manual/sql-data-types/date-time/datetime-overview.md: ########## @@ -24,11 +24,46 @@ specific language governing permissions and limitations under the License. --> +### Description +Date types include DATE, TIME and DATETIME, DATE type only stores the date accurate to the day, DATETIME type stores the date and time, which can be accurate to microseconds. TIME type only stores the time, and **does not support the construction of the table storage for the time being, can only be used in the query process**. +### Calculation and Type Convertion -The date data types include DATE and DATETIME: +When performing mathematical calculations on a date type, the date type will be converted to the corresponding numeric type (e.g. BIGINT, DOUBLE, etc.). The conversion is similar to number splicing, see the example below: -- **[DATE](../datetime/DATE.md)**: It stores only the date. The minimum precision unit is days. +```sql +mysql> select cast('2020-12-12' as date)*1; ++----------------------------------------------------+ +| (cast(cast('2020-12-12' as DATEV2) as BIGINT) * 1) | ++----------------------------------------------------+ +| 20201212 | ++----------------------------------------------------+ +1 row in set (0.12 sec) -- **[DATETIME](../datetime/DATETIME.md)**: It stores both the date and time. The minimum precision unit is milliseconds. \ No newline at end of file +mysql> select cast('2020-12-12 05:10:32.123456' as datetime(6))*1; ++---------------------------------------------------------------------------+ +| (cast(cast('2020-12-12 05:10:32.123456' as DATETIMEV2(6)) as BIGINT) * 1) | ++---------------------------------------------------------------------------+ +| 20201212051032 | Review Comment: 好的,我保证下这块儿case ########## i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-data-types/date-time/datetime-overview.md: ########## @@ -24,8 +24,46 @@ specific language governing permissions and limitations under the License. --> +### 描述 +日期类型包括 DATE、TIME 和 DATETIME,DATE 类型只存储日期精确到天,DATETIME 类型存储日期和时间,可以精确到微秒。TIME 类型只存储时间,且**暂时不支持建表存储,只能在查询过程中使用**。 -日期类型包括 DATE 和 DATETIME,DATE 类型只存储日期精确到天,DATETIME 类型存储日期和时间,可以精确到微秒。 +### 计算与转型 Review Comment: done ########## docs/sql-manual/sql-data-types/date-time/TIME.md: ########## @@ -0,0 +1,61 @@ +--- +{ + "title": "TIME", + "language": "en" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## TIME + +### name + +TIME + +### description + +TIME type + Time type, can appear as a query result, does not support table storage for the time being. The storage range is `[-838:59:59, 838:59:59]`. + Currently in Doris, the correctness of TIME as a result of calculations is guaranteed (e.g., functions such as `timediff`), but **manual CAST generation of the TIME type is not recommended**. + +### example + +```sql +mysql> select cast('100:00:00' as time); ++---------------------------+ +| cast('100:00:00' as TIME) | ++---------------------------+ +| 100:00:00 | ++---------------------------+ +1 row in set (0.11 sec) + +mysql> select timediff('2020-01-01', '2000-01-01'); ++------------------------------------------------------------------------------------+ +| timediff(cast('2020-01-01' as DATETIMEV2(0)), cast('2000-01-01' as DATETIMEV2(0))) | Review Comment: 这个是体现了上面那个上限的。time类型显示上限就是这么多。1.2是没有范围限制的 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org