Jump to content

Simple Date Query From MYSQL


ankycooper

Recommended Posts

hi ???

I Have a table named prop_tbl with a lot of feilds, one of the feilds is create_date which stores the timestamp of the record creation.

 

Now i want to pull up the records which are x months old.

 

 

please help

 

$months=10;
$nowstamp=time();
$expirestamp=strtotime("-$months month",$nowstamp);

"SELECT * FROM prop_tbl WHERE create_date<='$expirestamp'"

 

but it simply thows all the records

 

 

Please help I just want records whose create_date is greater than  equal to $months

Link to comment
https://forums.phpfreaks.com/topic/118090-simple-date-query-from-mysql/
Share on other sites

Do you want to show all the records that are OLDER than 10 months?

 

If so then I'd have thought:

 

$tenMonthOldTimestamp = time() - 24192000; (number of seconds in ten months..)

 

then

 

mysql_query("SELECT * FROM `prop_tbl` WHERE create_data <= '

$tenMonthOldTimestamp'");

 

E

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.