How do I extract Month and Year in a MySQL date and compare them?

前端 未结 6 2178
天涯浪人
天涯浪人 2020-12-05 22:51

How do I extract the month and date from a mySQL date and compare it to another date?

I found this MONTH() but it only gets the month. I looking for month and year.<

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 23:15

    You may want to check out the mySQL docs in regard to the date functions. http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

    There is a YEAR() function just as there is a MONTH() function. If you're doing a comparison though is there a reason to chop up the date? Are you truly interested in ignoring day based differences and if so is this how you want to do it?

提交回复
热议问题