-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
API4: add SQL Function DAYOFWEEK #26063
Conversation
(Standard links)
|
Hey @aydun this looks useful, thanks! |
@@ -234,6 +234,8 @@ public function testDateFunctions() { | |||
->addSelect('QUARTER(birth_date) AS quarter') | |||
->addSelect('MONTH(birth_date) AS month') | |||
->addSelect('EXTRACT(YEAR_MONTH FROM birth_date) AS year_month') | |||
->addSelect('DAYOFWEEK(birth_date) AS day_number') | |||
->addSelect('DAYNAME(birth_date) AS day_name') |
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.
->addSelect('DAYNAME(birth_date) AS day_name') | |
->addSelect('DAYOFWEEK(birth_date):label AS day_name') |
Should do the same thing right?
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.
Hmm - that produces:
There was 1 error:
1) api\v4\Action\SqlFunctionTest::testDateFunctions
CRM_Core_Exception: Aliasing field names is not allowed, only expressions can have an alias.
Hi @colemanw I agree it would be better just to have the one function, but how can I get the day name to show in SK results? The names show up in filters and where clauses, but not search results |
retest this please |
@aydun I think this needs a |
OK, let's see if that gets the tests to pass.... |
ok this seems to be passing tests now and Coleman has reviewed this so seems fine to me |
Thanks @seamuslee001 |
Overview
Adds day of week functions as SQL transformation. Let's you do things like 'find events on Wednesdays'
Before
No day of week functions
After
Day of week functions.
Technical Details
The SQL function returns 1-7, mapped to day names by the 'getOptions()' function.
Comments
Has test!