2

I've learned here How can I change the date format in a Search Kit result?, that I can change the output of a date (in my case birth_date) through rewrite-option and smarty. The reason why is, that I just want to sort the date by day and month to show next birthdays in ascending order.

So I tried {"[birth_date]"|date_format:"%d.%m."}

Unfortunately, the column is still sorted including the year of birth, i.e. according to the actual content and not according to the overwriting. Is there an option to manage this?

1 Answer 1

2

A workaround may be adding the 'Birth Date' field three times to the search and use functions for two (i.e one set to 'partial date' - days and the other to month only) and the full date for the third column.

You don't need to show the first two in your display but can still use them for sorting.

== Edit - add screenshot == enter image description here

3
  • Thank you Rebecca, that's exactly what I was trying. But the column for the day is sorted by the original content, not by the content with what I overwrite the original :-/
    – RomyE
    Commented Dec 19, 2022 at 9:51
  • @RomyE - Your post describes using smarty rewrites. The approach Rebecca describes is to use the Field Transformations section - I've added a screenshot.
    – Aidan
    Commented Dec 19, 2022 at 11:44
  • My Searchkit/CiviCRM Version was too old (5.53). After updating to 5.55 I found the partial date function and now it works. Thank you both very much!
    – RomyE
    Commented Dec 19, 2022 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.