dreampho Posted June 12, 2012 Share Posted June 12, 2012 Hi. I have a date in format YYYYMMDD. I want to display results where the MM is equal to something. How can I do this without it checking against the YYYY or DD? Thank you Link to comment https://forums.phpfreaks.com/topic/264038-where-part-of-date-is-equal-to/ Share on other sites More sharing options...
Illusion Posted June 12, 2012 Share Posted June 12, 2012 Check this.. http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_month Link to comment https://forums.phpfreaks.com/topic/264038-where-part-of-date-is-equal-to/#findComment-1353102 Share on other sites More sharing options...
dreampho Posted June 12, 2012 Author Share Posted June 12, 2012 Ah I see, thank you. But how would I add this into the WHERE? Thanks Link to comment https://forums.phpfreaks.com/topic/264038-where-part-of-date-is-equal-to/#findComment-1353105 Share on other sites More sharing options...
trq Posted June 12, 2012 Share Posted June 12, 2012 As an example, select records where the month is June: SELECT fld FROM tbl WHERE MONTH(some_date_fld) = '6'; Link to comment https://forums.phpfreaks.com/topic/264038-where-part-of-date-is-equal-to/#findComment-1353109 Share on other sites More sharing options...
dreampho Posted June 12, 2012 Author Share Posted June 12, 2012 Thank you for the example! Link to comment https://forums.phpfreaks.com/topic/264038-where-part-of-date-is-equal-to/#findComment-1353113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.