There is a table on mysql, which contains the birthdays of employees. It is necessary to look at the table once a day and look for birthdays, without paying attention to the year. I mean, today is 04/11/2012 and in the database there is Pupkin happy birthday 04/11/1990. It would be necessary to find this Pupkin and hit on the head ... Fields with dates like "DATETIME".
4 answers
Another option:
SELECT * FROM `table` WHERE Substring( `birthday` , 6, 5 ) = '04-11'
Or even like this:
SELECT * FROM `table` WHERE DATE_FORMAT( `birthday` , '%m-%d' ) = '04-11'
|
Search for everyone who has a birthday of the 12th in the 10th month:
SELECT * FROM tablename WHERE (DAY(birthday) = 12) AND (MONTH(birthday) = 10)
|
like request
WHERE birth LIKE '11.04.%'
- oneOh, I didn’t think about it right now) - KARTOH
- onethere is a contact only you need to write not '11 .04.% 'and'% 04-11% ' - KARTOH
|
I was looking for how to choose a birthday from the database for + -3 days relatively today, I didn’t find anything sensible, so I suggest my option, suddenly someone will come in handy:
select round(timestampdiff(day, date(birth_date), date(now())) / 365) as age, date_add(date(birth_date), interval round(timestampdiff(day, date(birth_date), date(now())) / 365) year) as new_birth, timestampdiff(day, date(now()), date_add(date(birth_date), interval round(timestampdiff(day, date(birth_date), date(now())) / 365) year)) as days_left, u.* from users as u having days_left >= -3 and days_left <= 3 order by days_left
|