diff --git a/expression/builtin_time.go b/expression/builtin_time.go index 7fddd000837aa..42b37ada48c38 100644 --- a/expression/builtin_time.go +++ b/expression/builtin_time.go @@ -5641,7 +5641,7 @@ func (b *builtinLastDaySig) evalTime(row chunk.Row) (types.Time, bool, error) { tm := arg.Time var day int year, month := tm.Year(), tm.Month() - if year == 0 && month == 0 && tm.Day() == 0 { + if month == 0 { return types.Time{}, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String())) } day = types.GetLastDay(year, month) diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go index c368dbd530a06..b2669ffb5a062 100644 --- a/expression/builtin_time_test.go +++ b/expression/builtin_time_test.go @@ -2428,6 +2428,8 @@ func (s *testEvaluatorSuite) TestLastDay(c *C) { "0000-00-00", "1992-13-00", "2007-10-07 23:59:61", + "2005-00-00", + "2005-00-01", 123456789} for _, i := range testsNull {