bcraig Posted October 6, 2008 Share Posted October 6, 2008 Im using PHP and i want to select records from my database where the month within a date datatype field is equal to a set variable. I dont know if this is possible? I have this now $dateFormat = date('m'); $monthNo = 10; $sql_month = sprintf("SELECT * FROM gigs WHERE '%s' = '%s'", $dateFormat, $monthNo); But that shows all records dated with all different months in the database Link to comment https://forums.phpfreaks.com/topic/127201-date-query/ Share on other sites More sharing options...
aebstract Posted October 6, 2008 Share Posted October 6, 2008 How is your table set up? Need a little bit more information to help you out here. Link to comment https://forums.phpfreaks.com/topic/127201-date-query/#findComment-658124 Share on other sites More sharing options...
Barand Posted October 7, 2008 Share Posted October 7, 2008 SELECT * FROM gigs WHERE MONTH(datecolname) = $monthNo Link to comment https://forums.phpfreaks.com/topic/127201-date-query/#findComment-658592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.