This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the user had a birthday field but wanted to get the next 3 posts with their upcoming birthdays. Solution:
The customer was able to resolve the issue with the query below.
SELECT user_id,FROM_UNIXTIME(`meta_value`) as bdate
FROM wp_usermeta
WHERE `meta_key` = 'wpcf-geboortedatum' AND DATE_ADD(FROM_UNIXTIME(`meta_value`),
INTERVAL YEAR(CURDATE())-YEAR(FROM_UNIXTIME(`meta_value`))
+ IF(DAYOFYEAR(CURDATE()) > DAYOFYEAR(FROM_UNIXTIME(`meta_value`)),1,0)
YEAR)
BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 1 YEAR) AND (MONTH(FROM_UNIXTIME(`meta_value`)) <> MONTH(CURDATE()) OR DAY(FROM_UNIXTIME(`meta_value`)) > DAY(CURDATE())) order by IF(MONTH(bdate) < MONTH(NOW()), MONTH(bdate) + 12, MONTH(bdate)),
DAY(bdate) limit 3
So essentially a custom database query is required for this
This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
If I understand correctly then you just want to return posts for the next 3 dates essentially since the next 3 dates would be birthdays.
Why not set your view to sort by the custom date field and then add a date filter for that birthday field and set it to list the days that are greater than today.
Finally you can adjust the limit to 3 so essentially your view will sort by the next days and only bring up posts that are 3 days in the future from today.
Please let me know if this provides any insight on this .
I have already followed the steps you mentioned above before generating support ticket.
Problem is, it is giving the birthdays which are grater than today respective of year.
So it is giving me users which are having birthday in current year and more than that year.
for example,
I have a Person with the birthday 12/14/1980
Today is 12/14/2017
If I set a filter by that date field and set the condition to the date to be after today like you said...it would never return that Person because the birthday is in the past and not after today (1980 is in the past)...
I was brainstorming and came up with an idea because i was running into some issues creating the filter.
Why not store each entity of the field in a separate custom field.
This way we can evaluate the day and month without having to worry about removing the year. So instead of having a datepicker we can create our own by create separate select fields for Month Day and Year where year can just be a simple numeric field.
So from this its still going to be difficult to get the next 3 birthdays but atleast its easier to query.
Thank You So Much Shane!!
I did it using below Query..It will help others.
SELECT user_id,FROM_UNIXTIME(`meta_value`) as bdate
FROM wp_usermeta
WHERE `meta_key` = 'wpcf-geboortedatum' AND DATE_ADD(FROM_UNIXTIME(`meta_value`),
INTERVAL YEAR(CURDATE())-YEAR(FROM_UNIXTIME(`meta_value`))
+ IF(DAYOFYEAR(CURDATE()) > DAYOFYEAR(FROM_UNIXTIME(`meta_value`)),1,0)
YEAR)
BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 1 YEAR) AND (MONTH(FROM_UNIXTIME(`meta_value`)) <> MONTH(CURDATE()) OR DAY(FROM_UNIXTIME(`meta_value`)) > DAY(CURDATE())) order by IF(MONTH(bdate) < MONTH(NOW()), MONTH(bdate) + 12, MONTH(bdate)),
DAY(bdate) limit 3
I have created shortcode to display it and deleted the view.