Jump to content

LIKE help with query please


simonjk

Recommended Posts

Hi,

 

I have a column in my mysql database which is a TIMESTAMP. This automatically updates each time an entry is made. The TIMESTAMP update is in the format YYYY-MM-DD HH:MM;SS.

 

I am trying to run the query below which retrieves data entered on a specific date from the table.

 

However, it seems that the query reads the first date that is similar and that is output (i.e. 2012-09-07, rather than look for the date that has been requests (say, 2012-09-09).

 

$daysresult = mysql_query("SELECT * FROM `hsgasjobsarchive` WHERE `Region`='Region' AND `Date` LIKE '$year-$month-$day_%'");

 

Am I doing something wrong in the like statement? I'd like the statement to ignore everything after $day.

 

Thanks in advance,

Simon

Link to comment
https://forums.phpfreaks.com/topic/268237-like-help-with-query-please/
Share on other sites

Thanks for the replies, but I don't see how this will help as the format of the date in the Date column (from TIMESTAMP) is YYYY-MM-DD HH:MM:SS, e.g. 2012-09-08 10:20.22 ?

 

Can the AND DATE(Date) = '$date' statement take a wildcard? As I could discard anything after $date?

 

Thanks again,

Simon

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.