Skip to content

DateTime toTime()'s epoch starts at 1970-01-*02* #2596

@soulne4ny

Description

@soulne4ny

It looks like this toTime() leads to wrong result

SELECT toDateTime('2018-01-01 00:00:00') + toRelativeSecondNum(toTime(toDateTime('2018-01-01 23:00:00'))) AS t
FORMAT Vertical

Row 1:
──────
t: 2018-01-02 23:00:00

Clues:

  1. Addition
SELECT toDateTime('2018-01-01 00:00:00') + 1 AS t
FORMAT Vertical

Row 1:
──────
t: 2018-01-01 00:00:01
  1. toTime()
SELECT toTime(toDateTime('2018-01-01 00:00:00')) AS t
FORMAT Vertical

Row 1:
──────
t: 1970-01-02 00:00:00

SELECT toRelativeSecondNum(toTime(toDateTime('2018-01-02 00:00:00'))) AS t
FORMAT Vertical

Row 1:
──────
t: 86400

Version info

  • clickhouse-server 1.1.54388 (docker image yandex/clickhouse-server af405db7538d)
  • ubuntu 18.04 LTS
  • docker 18.03.1-ce

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