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 Quote 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"; Quote 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 Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.