diff --git a/go/vt/vtgate/evalengine/compiler_asm.go b/go/vt/vtgate/evalengine/compiler_asm.go index 161e3525b5d..1a750ed7d0e 100644 --- a/go/vt/vtgate/evalengine/compiler_asm.go +++ b/go/vt/vtgate/evalengine/compiler_asm.go @@ -3784,11 +3784,12 @@ func (asm *assembler) Fn_LAST_DAY() { return 1 } arg := env.vm.stack[env.vm.sp-1].(*evalTemporal) - d := lastDay(env.currentTimezone(), arg.dt) - if d.IsZero() { + if arg.dt.IsZero() { env.vm.stack[env.vm.sp-1] = nil return 1 } + + d := lastDay(env.currentTimezone(), arg.dt) env.vm.stack[env.vm.sp-1] = env.vm.arena.newEvalDate(d) return 1 }, "FN LAST_DAY DATETIME(SP-1)") diff --git a/go/vt/vtgate/evalengine/fn_time.go b/go/vt/vtgate/evalengine/fn_time.go index 45fa5ad447e..de1b7259aff 100644 --- a/go/vt/vtgate/evalengine/fn_time.go +++ b/go/vt/vtgate/evalengine/fn_time.go @@ -1228,10 +1228,6 @@ func (b *builtinLastDay) eval(env *ExpressionEnv) (eval, error) { } d := lastDay(env.currentTimezone(), dt.dt) - if d.IsZero() { - return nil, nil - } - return newEvalDate(d, env.sqlmode.AllowZeroDate()), nil }