pemula Posted September 5, 2011 Share Posted September 5, 2011 My db: CREATE TABLE `tb_event` ( `id` tinyint(4) NOT NULL auto_increment, `t_date` date default NULL, `t_event` varchar(75) default NULL, `t_place` varchar(75) default NULL, `t_content` text, PRIMARY KEY (`id`) ) Records: 1, '2011-01-09', 'event 1', ... 2, '2011-05-12', 'event 2', ... 3, '2011-09-20', 'event 3', ... ------- My code here: <? $now = date("Y-m-d"); ... ... SELECT * FROM tb_acara WHERE t_tanggal >= $now ... ... ?> It will show all records.. I change >= with <= it didn't show anything ------- My goal is: I only want to show the event which in September (month of 9) on record number 3 Can you help me please guys?? Thanks Link to comment https://forums.phpfreaks.com/topic/246453-showing-event-this-month-only/ Share on other sites More sharing options...
manohoo Posted September 5, 2011 Share Posted September 5, 2011 You are confusing me, you are creating table 'tb_event' but... you are querying table 'tb_acara'..... Assuming that your query is against table 'tb_event' this what I would do to retrieve September events: $sql = "SELECT * FROM tb_event WHERE MONTH(t_date)=9"; Link to comment https://forums.phpfreaks.com/topic/246453-showing-event-this-month-only/#findComment-1265560 Share on other sites More sharing options...
pemula Posted September 5, 2011 Author Share Posted September 5, 2011 ooops sory, I didn't correct and recheck myposting Btw, thnks for reply Link to comment https://forums.phpfreaks.com/topic/246453-showing-event-this-month-only/#findComment-1265562 Share on other sites More sharing options...
pemula Posted September 5, 2011 Author Share Posted September 5, 2011 and it solved with this... SELECT * FROM tb_event WHERE YEAR(t_date)=YEAR(Now()) AND MONTH(t_date)=MONTH(Now()) AND DATE(t_date)>=DATE(Now()) thx for manohoo Link to comment https://forums.phpfreaks.com/topic/246453-showing-event-this-month-only/#findComment-1265576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.