-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
implement last_days()
#2460
implement last_days()
#2460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
sql/expression/function/days.go
Outdated
@@ -232,3 +232,82 @@ func (f *FromDays) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) { | |||
months, days := daysToMonth(years, days) | |||
return time.Date(int(years), time.Month(months), int(days), 0, 0, 0, 0, time.UTC), nil | |||
} | |||
|
|||
// LastDay is a function that the date but at the last day of the month. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// LastDay is a function that the date but at the last day of the month. | |
// LastDay is a function that returns the date at the last day of the month. |
arg: expression.NewLiteral("0001-11-00", types.Text), | ||
exp: time.Date(1, 11, 30, 0, 0, 0, 0, time.UTC), | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(minor) might be worth adding another date that has an incorrect day for the month, like 2020-02-30
or something.
mysql docs:
https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_last-day