Jump to content

Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/148216-solved-sql-query-problem/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.