Skip to content

Error converting string to date #158

Closed

Description

@sichkarev

ClickHouse client version 1.1.54030.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54030.
:) select toDate('1967-01-01')
SELECT toDate('1967-01-01')
┌─toDate('1967-01-01')─┐
│ 0000-00-00 │
└────────────────────────┘

1 rows in set. Elapsed: 0.002 sec.

Activity

  1. alexey-milovidov commented on Nov 2, 2016

    @alexey-milovidov
    Member

    Only dates after the beginning of the unix epoch are supported. As documented here:
    https://clickhouse.yandex/reference_en.html#Date

    You could use different data type (String or UInt32) to store broader range of dates,
    but datetime functions will not work with them.

  2. sichkarev commented on Nov 3, 2016

    @sichkarev
    Author

    Alexey, thank you for answer! It sad restrictions.
    Please tell me the best way to store birthdate user? May be date split by 3 columns: year, month and day? And say please how best way for grouping users by age and period 0 - 20, 20 - 40 years old?

    Thank you so much!

  3. sichkarev commented on Nov 8, 2016

    @sichkarev
    Author

    image
    I did it :)
    @alexey-milovidov may be you think best way for task?

    select 
        sumIf(cnt, age between 0 and 13) as yo_13, /*от 0 до 13*/
        sumIf(cnt, age between 14 and 17) as yo_17, /*от 14 до 17*/
        sumIf(cnt, age between 18 and 24) as yo_24, /*от 18 до 24*/
        sumIf(cnt, age between 25 and 29) as yo_29, /*от 25 до 29*/
        sumIf(cnt, age between 30 and 44) as yo_44, /*от 30 до 44*/
        sumIf(cnt, age between 45 and 54) as yo_54, /*от 45 до 54*/
        sumIf(cnt, age between 55 and 85) as yo_85, /*от 55 до 85*/
        sumIf(cnt, age > 85) as yo_more /*от 85 и более*/
    from (
            select toYear(today()) - year_of_birth - ((toMonth(today()) - month_of_birth < 0) or (toMonth(today()) - month_of_birth == 0 and toDayOfMonth(today()) - day_of_birth < 0) ? 1 : 0) as age, sum(cnt) as cnt from (
                select year_of_birth, month_of_birth, day_of_birth, count() as cnt from TABLE group by year_of_birth, month_of_birth, day_of_birth
            ) group by age
    ) FORMAT Vertical
  4. alexey-milovidov commented on Nov 12, 2016

    @alexey-milovidov
    Member

    I have no better solution. I wanted to propose the same.

  5. yehiaelbehery commented on Feb 21, 2020

    @yehiaelbehery

    Do you plan to supporting date functions for dates before 1970 for birth dates, ... and other historic dates. Can you explain the philosohy behind the decision (if not time and resources)?

  6. den-crane commented on Feb 21, 2020

    @den-crane
    Contributor

    @yehiaelbehery yes. It will be implemented in DateTime64 #7316

  7. added a commit that references this issue on Jun 29, 2022
  8. added 2 commits that reference this issue on Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions