MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / registerDataTypeDate

Function registerDataTypeDate

src/DataTypes/DataTypeDate.cpp:18–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void registerDataTypeDate(DataTypeFactory & factory)
19{
20 factory.registerSimpleDataType("Date", [] { return DataTypePtr(std::make_shared<DataTypeDate>()); }, DataTypeFactory::Case::Insensitive,
21 Documentation{
22 .description = R"DOCS_MD(
23A date. Stored in two bytes as the number of days since 1970-01-01 (unsigned). Allows storing values from just after the beginning of the Unix Epoch to the upper threshold defined by a constant at the compilation stage (currently, this is until the year 2149, but the final fully-supported year is 2148).
24
25Supported range of values: \[1970-01-01, 2149-06-06\].
26
27The date value is stored without the time zone.
28
29**Example**
30
31Creating a table with a `Date`-type column and inserting data into it:
32
33```sql
34CREATE TABLE dt
35(
36 `timestamp` Date,
37 `event_id` UInt8
38)
39ENGINE = TinyLog;
40```
41
42```sql
43-- Parse Date
44-- - from string,
45-- - from 'small' integer interpreted as number of days since 1970-01-01, and
46-- - from 'big' integer interpreted as number of seconds since 1970-01-01.
47INSERT INTO dt VALUES ('2019-01-01', 1), (17897, 2), (1546300800, 3);
48
49SELECT * FROM dt;
50```
51
52```text
53┌──timestamp─┬─event_id─┐
54│ 2019-01-01 │ 1 │
55│ 2019-01-01 │ 2 │
56│ 2019-01-01 │ 3 │
57└────────────┴──────────┘
58```
59
60**See Also**
61
62- [Functions for working with dates and times](../../sql-reference/functions/date-time-functions.md)
63- [Operators for working with dates and times](../../sql-reference/operators#operators-for-working-with-dates-and-times)
64- [`DateTime` data type](../../sql-reference/data-types/datetime.md)
65)DOCS_MD",
66 .syntax = "Date",
67 .related = {"Date32", "DateTime"},
68 });
69}
70
71}

Callers 1

DataTypeFactoryMethod · 0.85

Calls 1

Tested by

no test coverage detected