Skip to Content Skip to Menu

Trying to create a birthday list, using advanced sorting

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
7 years 1 month ago #297457 by fribse2011
I'm trying to create a CB list with upcoming birthday, so I need the sorting to ignore the year of course.

I found some sql examples online, but I can't get them working:

This doesn't work, and it doesn't consider the current date:
month(ue.'cb_birthday') ASC, dayofmonth(ue.'cb_birthday') ASC

datepart(dy,dateadd(d,- DATEPART(dy, getdate()),ue.'cb_birthday' ))

It could be way out of scope for the product, but it would be nice to have the list show somewhere on the page :-)

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
7 years 1 month ago #297462 by krileon
Ordering by birthday is just a matter of using MONTH then DAY order by on the birthdate if you want to exclude year otherwise you have to normalize the year and order by the result. Gets a lot more complicated to order by upcoming birthday. See the below.

www.google.com/search?q=sql+order+by+upcoming+birthdays

stackoverflow.com/questions/7343807/mysql-query-to-sort-upcoming-birthdays-based-on-current-date

The Advanced usage under Order By lets you directly add to the query so you'll be able to do this, but you'll need to provide the SQL. Likely won't be very efficient though.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: fribse2011

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum