search

Home  >  Q&A  >  body text

php - Query problem of today's birthday in solar calendar and lunar calendar result set.

Database Design

is_lunar Whether the lunar calendar (0=solar calendar, 1=lunar calendar)
birthday birthday (date type directly saves the birthday format 1985-07-19)

question

How to query the record set of today’s birthday?

ps: Mysql’s date function knowledge is almost zero. I don’t know how to write it. I hope you guys can give me some advice. I’m very grateful.

First supplement

This is how I write it now, it should be no problem.

$solar = 当前阳历月份和日(04-11)
$lunar = 当前农历月份和日(03-15)
select * from table where ( is_lunar = 0 and date_format(birthday, '%m-%d') = {$solar} ) or ( is_lunar = 1 and DATE_FORMAT(birthday,'%m-%d') = {$lunar}) 
ringa_leeringa_lee2782 days ago541

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:18:34

    I know a PHP class for converting lunar calendar and solar calendar. It is recommended to use PHP to convert it, and then query it after confirming a date.
    SQL can probably be like this, select * from users where (is_lunar = 1 and birthday = 2017-03-15) or (is_lunar = 0 and birthday = 2017-04-11)

    reply
    0
  • Cancelreply