GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   MYSQL Help Needed with CURDATE() (https://gfy.com/showthread.php?t=1046428)

eMonk 11-18-2011 09:30 PM

MYSQL Help Needed with CURDATE()
 
I'm trying to only fetch the rows where the expiry_date column is 3 days before today's date.

Code:

<?php

include("../includes/connect.php");

$query = "SELECT expiry_date FROM model WHERE expiry_date BETWEEN CURDATE() AND CURDATE() - INTERVAL 3 DAY";
$result = $db->query($query);

$num_results = $result->num_rows;

echo "$num_results";

?>

$num_results should echo "1" because there is 1 expiry_date column with "2011-11-17" but it's echoing "0". Any ideas?

woj 11-18-2011 09:35 PM

flip the 2 paramaters CURDATE() AND CURDATE() - INTERVAL 3 DAY

what you have there is like asking for all numbers between 5 and 3, you need to ask for all numbers between 3 and 5

marlboroack 11-18-2011 09:41 PM

Cool signature.

eMonk 11-18-2011 09:41 PM

That worked thanks woj!!


All times are GMT -7. The time now is 01:28 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123