ferret147 Posted March 6, 2009 Share Posted March 6, 2009 I am using Dreamweaver to make a On This Day scrips, I already have a database populated but just having a slight problem getting the info I want displayed. In the database I have a date field for each record formatted like this yyyy-mm-dd, when the year changes I have to go through the entire database and change it from say for this year 2008 to 2009 to get my records to display, so I am trying to give the year a wild card so if any entrys match the month and day they will display instead this will save me loads of time every year going through the database and changing the year. Below is the code I have so far but all it displays is the first entry in the database. Can anybody please advise as to where I am going wrong or even if I am going in the right direction for this. $today = date("%%%%-m-d"); $query_Recordset1 = sprintf("SELECT * FROM OnThisDay WHERE `date` = '$today'", $colname_Recordset1); Quote Link to comment https://forums.phpfreaks.com/topic/148216-solved-sql-query-problem/ Share on other sites More sharing options...
Mchl Posted March 6, 2009 Share Posted March 6, 2009 SELECT * FROM OnThisDay WHERE MONTH(`date`) = MONTH(CURDATE()) AND DAY(`date`) = DAY(CURDATE()) or SELECT * FROM OnThisDay WHERE DATE_FORMAT(`date`,'%e-%m') = DATE_FORMAT(CURDATE(),'%e-%m') or... there are possibly dozens other ways to do this See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment https://forums.phpfreaks.com/topic/148216-solved-sql-query-problem/#findComment-778026 Share on other sites More sharing options...
ferret147 Posted March 6, 2009 Author Share Posted March 6, 2009 Top bananna, that worked a treat, easy when you know how I suppose. Thanks ferret Quote Link to comment https://forums.phpfreaks.com/topic/148216-solved-sql-query-problem/#findComment-778047 Share on other sites More sharing options...
Mchl Posted March 6, 2009 Share Posted March 6, 2009 Take some time to familirise yourself with MySQL functions (don't learn them by heart, just read the list to know what functions are available). This will increase your 'know how' factor Quote Link to comment https://forums.phpfreaks.com/topic/148216-solved-sql-query-problem/#findComment-778052 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.