Hello,

With Drupal 6, there was a nice module called "Birthdays"; it provided a block with a list of upcoming birthdays : username (age) | day/month. This module has not been ported on D7 (nor BD) and I can't find a similar module.

I consider to recreate the functionality by using views but struggle with this approach...

  • Module Views Conditional has been installed
  • Profile has field "Birthday" (User account: Birthday = Birthday field_birthday    Date    Pop-up calendar)
  • Views birthday is created with Field Birthday and filter User account: Birthday (now) (Is greater or equal to | enter relative date | now)

This would work if the defined birthday had the current year (which is of course not the case).

How can I filter based on the day and month only?

Or should I consider another approach?

Thanks!

Most helpful answers

Hi Patch-works! This is a tricky problem that (AKAIK) can't be solved with Views filters or sorts as-is. You'll need to create some custom SQL "order by" code to be added to your "normal" Views SQL query. The module Views Raw SQL  will allow you to add custom SQL code to the existing query - but it will require some trial and error. Also, this approach to birthday sorting through sql commands can be helpful (it will need to be adapted).

Otherwise, perhaps porting the module you mentioned? 

Comments

Hi Patch-works! This is a tricky problem that (AKAIK) can't be solved with Views filters or sorts as-is. You'll need to create some custom SQL "order by" code to be added to your "normal" Views SQL query. The module Views Raw SQL  will allow you to add custom SQL code to the existing query - but it will require some trial and error. Also, this approach to birthday sorting through sql commands can be helpful (it will need to be adapted).

Otherwise, perhaps porting the module you mentioned? 

Hi argiepiano, thanks for your answer! Porting a module is unfortunately not a competence I have...  I indeed identified the modules views calc and views raw sql; so I will have a try.

It does look like some work was done on the D7 version of Birthdays but it does say it is not stable and there are 11 open bugs reported so it could be problematic to port to Backdrop.

Hi patch-works

I did something similar with Drupal 7: a block with aniversaries of historical dates. You can see it at https://lassalle-kreis.de/ down in the blue footer, the middle column.

This is a view for content type *jahrestag* (aniversary)

The content type has two fields
- the historical date (used for sorting)
- the repeat-date as date-field, I collect only month and day (of the historical date) and set *Repeating date* to true .

In the view I use the 
- historical date for sorting
- the repeating date as filter like so: relative date is greater or equal *now* and in the settings I choose *Day* for filter granularity

There are two modules for repeated dates in Backdrop. I havent' tried them yet. Hope this helps you.

Regards
Conni

Hi Conni, Thank you for your suggestion, it is indeed very close to what I'm looking for. We are currently busy with content transfer, but I will have a try soon.