Skip to content

Conversation

@angelamayxie
Copy link
Contributor

@angelamayxie angelamayxie commented Nov 14, 2025

Fixes dolthub/dolt#10075

Our datetime functions were not returning the correct results for 0 and false. This was because we were using 0000-01-01 as zeroTime (which evaluates to true using Go's time.IsZero) and then extracting datetime information from that timestamp. Using 0000-01-01 as zeroTime was also giving incorrect results for some functions when the input timestamp was actually 0000-01-01, since it was being equated as zeroTime.

Also, depending on whether false was read as false or 0, we were also not able to convert it to zeroTime.

This fix involves updating zeroTime to time.Date(0, 0, 0, 0, 0, 0, 0, time.UTC), which has the timestamp -0001-11-30. Since negative years are not valid in MySQL, this timestamp would not conflict with a non-zero timestamp. We also add in checks for zeroTime to make sure functions return the correct value from zeroTime instead of simply extracting datetime information from the timestamp.

Dolt bump PR: dolthub/dolt#10084

@angelamayxie angelamayxie marked this pull request as ready for review November 17, 2025 22:16
Copy link
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@angelamayxie angelamayxie merged commit 49b8a44 into main Nov 18, 2025
7 of 8 checks passed
@angelamayxie angelamayxie deleted the angela/date_functions branch November 18, 2025 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected DAYOFMONTH Result

3 participants