Skip to content

toStartOf...() incorrect result when out of normal range #22928

@zvonand

Description

@zvonand

All toStartOf...() functions except toStartOfSecond() returns wrong result when out of normal range:

SELECT toStartOfDay(toDateTime64('1969-12-31 12:12:12', 0, 'UTC'))

┌─toStartOfDay(toDateTime64('1969-12-31 12:12:12', 0, 'UTC'))─┐
│                                         2106-02-06 06:28:16 │
└─────────────────────────────────────────────────────────────┘

SELECT toStartOfISOYear(toDateTime64('1969-12-31 12:12:12', 0, 'UTC'))

┌─toStartOfISOYear(toDateTime64('1969-12-31 12:12:12', 0, 'UTC'))─┐
│                                                      2149-06-04 │
└─────────────────────────────────────────────────────────────────┘

A slightly different type of error is given by toStartOfSecond():

SELECT toStartOfSecond(toDateTime64('1928-12-31 12:12:12.123', 3, 'UTC'))

┌─toStartOfSecond(toDateTime64('1928-12-31 12:12:12.123', 3, 'UTC'))─┐
│                                            1928-12-31 12:12:11.000 │
└────────────────────────────────────────────────────────────────────┘

ClickHouse version 21.5.1.6463

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-datetimeDate/DateTime/TimeZone datatypes and date-time semantics.unfinished code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions