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

Casting Timestamp to date is off by one day for dates before 1970-01-01 #4211

Closed
parthchandra opened this issue May 12, 2023 · 2 comments · Fixed by #4323
Closed

Casting Timestamp to date is off by one day for dates before 1970-01-01 #4211

parthchandra opened this issue May 12, 2023 · 2 comments · Fixed by #4323
Assignees
Labels
arrow Changes to the arrow crate bug

Comments

@parthchandra
Copy link
Contributor

If casting a negative number of micros/millis to date, the cast method divides by the number of (micro/milli)seconds to get the number of days from the beginning of the epoch.
For a timestamp like 1969/12/31 23:59:59.995 (in millis) the number of millis from beginning of the epoch is -5. The division by the number of seconds in a day yields 0 which is off by one day since it should be -1.

To Reproduce

select '1969-12-31 00:00:01'::timestamp::date;
+-----------------------------+
| Utf8("1969-12-31 00:00:01") |
+-----------------------------+
| 1970-01-01                  |
+-----------------------------+

Expected behavior

select '1969-12-31 00:00:01'::timestamp::date;
+-----------------------------+
| Utf8("1969-12-31 00:00:01") |
+-----------------------------+
| 1960-12-31                  |
+-----------------------------+
@comphead
Copy link
Contributor

Reverified that on PG it works as @parthchandra expects

select '1969-12-31 00:00:01'::timestamp::date;


    date    
------------
 1969-12-31
(1 row)

@tustvold
Copy link
Contributor

tustvold commented Jun 2, 2023

label_issue.py automatically added labels {'arrow'} from #4323

@tustvold tustvold added the arrow Changes to the arrow crate label Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants