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

Wrong timestamp to date cast for dates predating 1970-01-01 #42937

Closed
lukaseder opened this issue Dec 4, 2019 · 0 comments · Fixed by #42952
Closed

Wrong timestamp to date cast for dates predating 1970-01-01 #42937

lukaseder opened this issue Dec 4, 2019 · 0 comments · Fixed by #42952
Assignees
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.

Comments

@lukaseder
Copy link

Describe the problem

When casting a timestamp before 1970-01-01 to date, a wrong result is produced

To Reproduce

Run this SQL query in PostgreSQL and CockroachDB:

select ts, ts::date
from (values 
  (timestamp '1969-12-30 01:00:00'),
  (timestamp '1970-12-30 01:00:00')
) t (ts);

The expected result (as observed in PostgreSQL) is that both timestamps are truncated to December 30:

ts ts
1969-12-30 01:00:00 1969-12-30
1970-12-30 01:00:00 1970-12-30

However, in CockroachDB, I'm getting:

ts ts
1969-12-30 01:00:00 1969-12-31
1970-12-30 01:00:00 1970-12-30

I'm using:

show timezone;

Europe/Berlin

Environment:

  • CockroachDB version: CockroachDB CCL v19.2.1 (x86_64-unknown-linux-gnu, built 2019/11/18 23:23:55, go1.12.12)
  • Server OS: Linux on Docker on Windows
  • Client app: JDBC
@awoods187 awoods187 added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-pgcompat Semantic compatibility with PostgreSQL labels Dec 4, 2019
@awoods187 awoods187 added the S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption. label Dec 4, 2019
@craig craig bot closed this as completed in 28f216e Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants