Skip to content
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

SearchKit - Add next_birthday calc field #25740

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Mar 6, 2023

Overview

Adds a calculated field to make it easy to perform "upcoming birthday" searches.

Before

Could not create "upcoming birthday" searches in SearchKit.

After

image

Technical Details

This field returns an integer from 0 (birthday is today) to 364 (birthday was yesterday). Or maybe on leap years that would be 365.

@civibot
Copy link

civibot bot commented Mar 6, 2023

(Standard links)

@civibot civibot bot added the master label Mar 6, 2023
@eileenmcnaughton
Copy link
Contributor

@colemanw I feel like as soon as we add this people will want the actual date (e.g to include in a calendar) - would it be hard to add that too?

@colemanw
Copy link
Member Author

colemanw commented Mar 6, 2023

@eileenmcnaughton you can already get the birth month and the birth day using field transformations, and you could put them together in a single field using rewrite. Or you could use rewrite plus a smarty date formatter to leave off the year.

@eileenmcnaughton
Copy link
Contributor

OK - well this is useful - we can worry about the other if it arises - I still think the field re-write for a feed is harder than it might appear as you can't just combine date+month + this year - cos it might be next year

@eileenmcnaughton eileenmcnaughton merged commit db5fdfd into civicrm:master Mar 6, 2023
@eileenmcnaughton eileenmcnaughton deleted the nextBirthday branch March 6, 2023 20:52
@colemanw
Copy link
Member Author

colemanw commented Mar 6, 2023

cos it might be next year

Yea actually it will be every year. I'm not quite sure how you do that with a cal feed, but I guess generating one for this year and one for next year is pretty good.

@jofranz
Copy link
Contributor

jofranz commented Mar 7, 2023

@jensschuppe Glad I didn't refactor birthday reports :D Thanks @colemanw !

@WebmasterBouclier
Copy link

@colemanw Thanks again for this quick and wonderful answer. You made my day :-)
As promised, I tried a few configurations, and all seems to work fine.
Tested:

  • Next birthday in ≤ 7 days : OK
  • Next birthday in ≤ 400 days : OK, only displays the contact once, over the next 365 days
  • Next birthday in ≤ -30 days: OK, no result displayed
  • Next birthday in ≥ 0 days : OK, all contacts with birthdate displayed, only once

Peter

@colemanw
Copy link
Member Author

colemanw commented Mar 8, 2023

Glad it's working for you @WebmasterBouclier, thanks for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants