I want to select the next upcoming birthdays in MYSQL.
My date is stored as: 02/19/1981 and not in a date field. I think it has to sort by day and month and not year but i can not find out how.
How can i do this? This is the query till now:
$sql = "SELECT * FROM wp_postmeta WHERE meta_key='_web_date' ORDER BY ....";
If it’s possible for you change the date column to type date.
Otherwise try this:
Result:
You can use the php date() function. For example ate(‘Y-m-d’,strtotime(“+7 day”)); then create a sql query which selects dates which are in the upcoming 7 days
This is a test environment.
I created this function to get the next birthday. The logic may throw some interesting results over 29th Feb / 1st March.
Then you can do a query and order by next_birth_day:
giving results like this: