Skip to content

wrongly convert datetime for 1970-01-01 08:00:00 #12377

@hellflame

Description

@hellflame

Describe the bug

can not convert datetime string '1970-01-01 08:00:00' to correct datetime value

SELECT toDateTime('1970-01-01 08:00:00', 'Asia/Shanghai')

┌─toDateTime('1970-01-01 08:00:00', 'Asia/Shanghai')─┐
│                                0000-00-00 00:00:00 │
└────────────────────────────────────────────────────┘

1 rows in set. Elapsed: 0.001 sec.

and 1 second later

SELECT toDateTime('1970-01-01 08:00:01', 'Asia/Shanghai')

┌─toDateTime('1970-01-01 08:00:01', 'Asia/Shanghai')─┐
│                                1970-01-01 08:00:01 │
└────────────────────────────────────────────────────┘

1 rows in set. Elapsed: 0.001 sec.

How to reproduce

  • Which ClickHouse server version to use: 20.4.6.53 (official build) | ClickHouse server version 20.4.6 revision 54434
  • Which interface to use, if matters : clickhouse-client
  • Non-default settings, if any: default
  • Queries to run that lead to unexpected result
select toDateTime('1970-01-01 08:00:00', 'Asia/Shanghai')

Expected behavior

should be 1970-01-01 08:00:00

it will be great if timezone info is displayed or returned

and when the time is ahead of 1970-01-01 or the time is out of range, the convert will be

┌─toDateTime('1970-01-01 07:00:01', 'Asia/Shanghai')─┐
│                                2106-02-07 13:28:17 │
└────────────────────────────────────────────────────┘

converting to 0000-00-00 00:00:00 is considerably a better acceptable choice, much easier to be marked as exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-datetimeDate/DateTime/TimeZone datatypes and date-time semantics.duplicateunexpected behaviourResult is unexpected, but not entirely wrong at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions