date query returning incorrectly

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Obadiah
Forum Regular
Posts: 580
Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:

date query returning incorrectly

Post by Obadiah »

im running this query

Code: Select all

$sql="SELECT * FROM merchant WHERE user_name = '{$_SESSION['logname']}' AND create_date<=DATE_SUB(CURDATE(), INTERVAL 30 DAY) order by date_recieved";
and for some reason its returning values from december....what would be the reason for this?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Not sure. Maybe you could try searching the database using date() and mktime()...
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

december is before the 3 January, you are asking to return records less than or equal to 3 January.
Post Reply