Repository navigation
Add this year function - #48321
Add this year function#483212063436123 wants to merge 3 commits into
Conversation
| ## toYear | ||
|
|
||
| Converts a date or date with time to a UInt16 number containing the year number (AD). | ||
| Also accepts zero arguments and returns the current year at one of the moments of query analysis. The same as ‘toYear(now())’ or ‘toYear(today())’. |
There was a problem hiding this comment.
"at one of the moments of query analysis" sounds obvious and weird. Yes, the wording was copypasted from other places in this file. It would be nice if you could omit that phrase in all places in this document.
Also, it's just fine to mention toYear(now()) instead of toYear(now()) or toYear(today()).
--> "Also accepts zero arguments in which it returns the current year, i.e. toYear(now())"
| ## toYear | ||
|
|
||
| Converts a date or date with time to a UInt16 number containing the year number (AD). | ||
| Also accepts zero arguments and returns the current year at one of the moments of query analysis. The same as ‘toYear(now())’ or ‘toYear(today())’. |
There was a problem hiding this comment.
From a usage POV, a zero-argument form of toYear/YEAR is nice, but the user will wonder why a similar syntax is not available for toQuarter()/toMonth()/toDayOfYear()/toDayOfMonth()/toDayOfWeek()/toHour()/toMinute()/toSecond(). It will be perceived as inconsistency. Would it be possible to implement the same also for the listed functions?
There was a problem hiding this comment.
maybe I should create a new function with name thisYear()? But it looks strange.
There was a problem hiding this comment.
@2063436123 Can't we just add this behavior to other functions?
There was a problem hiding this comment.
@evillique yes, I'm planning to realize a new function thisYear().
There was a problem hiding this comment.
Why is a separate function needed? Current solution is great and we only need to add similar behavior to other functions like quarter() = quarter(now()), month() = month(now()), etc
There was a problem hiding this comment.
Sorry, I misunderstood your last comment, you are right, we should add this new syntax, of course, it will add a lot of new usages of functions.
|
@jjyep101 Could you please ask more specifically about certain behavior or design? The classes you mentioned are base classes used by different date-time related functions. |
There was a problem hiding this comment.
This new bit of code is to display the current year when year() is called, correct?
There was a problem hiding this comment.
Why are you error checking a 0 argument size here? Don't you want 0 arguments to pass?
There was a problem hiding this comment.
This bit of code is where it translates year() the same as year(now()), correct?
|
@evillique I'd prefer if only |
|
I thought it was for MySQL compatibility, but I checked - MySQL does not have a function year without arguments. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add function year() with no arguments that returns current year.
year()= year(now()) = year(today()).Documentation entry for user-facing changes