Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date/Date32/DateTime/DateTime64 min value read as 0001-01-01 #60

Open
MaceWindu opened this issue Jun 27, 2022 · 5 comments
Open

Date/Date32/DateTime/DateTime64 min value read as 0001-01-01 #60

MaceWindu opened this issue Jun 27, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@MaceWindu
Copy link
Contributor

MaceWindu commented Jun 27, 2022

CREATE TABLE IF NOT EXISTS TypeTable
(
	Id             Int32  NOT NULL,
	Column         Date32 NOT NULL,
)
ENGINE = Memory()

INSERT INTO TypeTable
(
	Id,
	Column
)
VALUES
(toInt32(1),toDate32('1925-01-01'))

Data reader's GetValue/GetDate method returns default value 0001-01-01 instead of actual value from table.
Works fine for max-value (2283-11-11) or 1925-01-02.

@SergeyMirvoda SergeyMirvoda added the bug Something isn't working label Jun 27, 2022
@MaceWindu
Copy link
Contributor Author

Actually, same issue for Date and 1970-01-01 value

@MaceWindu MaceWindu changed the title Date32 value 1925-01-01 read as 0001-01-01 Date/Date32/DateTime min value read as 0001-01-01 Jun 27, 2022
@MaceWindu
Copy link
Contributor Author

DateTime affected too. Not tested DateTime64 yet, but probably also affected.

@MaceWindu MaceWindu changed the title Date/Date32/DateTime min value read as 0001-01-01 Date/Date32/DateTime min value read as 0001-01-01. DateTime64 throws exception Jul 2, 2022
@MaceWindu
Copy link
Contributor Author

MaceWindu commented Jul 2, 2022

DateTime64 also returns 0001-01-01 for 1970-01-01
Values prior to this date result in exception #62

@MaceWindu MaceWindu changed the title Date/Date32/DateTime min value read as 0001-01-01. DateTime64 throws exception Date/Date32/DateTime/DateTime64 min value read as 0001-01-01 Jul 2, 2022
@Alex69rus
Copy link

I don't get DateTime.MinValue value while fetching DateTime64 fields with value less than 1970-01-01, but I get exception:

Octonica.ClickHouseClient.Exceptions.ClickHouseHandledException
The value must be in range [1970-01-01T00:00:00.0000000+00:00, 9999-12-31T23:59:59.9999999+00:00].
CREATE TABLE IF NOT EXISTS TypeTable
(
    Id            Int32,
    Column  DateTime64
)
    ENGINE = Memory();

INSERT INTO TypeTable (Id, Column) VALUES (1, toDateTime64('1925-01-01', 3));

Fetching code:

public class TypeTable
{
    int            Id     { get; set; }
    DateTimeOffset Column { get; set; }
}

var result = await _connection.QueryFirstOrDefaultAsync<TypeTable>("SELECT * FROM TypeTable");

@Alex69rus
Copy link

Also there is a problem with filtering by DateTime64 values:

var result = await _connection.QueryFirstOrDefaultAsync<TypeTable>(
    new CommandDefinition(
      "SELECT * FROM TypeTable WHERE Column > {DateTimeFilter:DateTime64}",
      new Dictionary<string, object>
      {
          { "DateTimeFilter", new DateTimeOffset(1930, 1, 1, 1, 1, 1, TimeSpan.Zero) }
      }
  )
);

Exception:

Octonica.ClickHouseClient.Exceptions.ClickHouseHandledException
The value must be in range [1970-01-01 00:00:00, 2105-12-31 23:59:59].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants