here is what i wanna do. I want to take the joindate and compare it to the current date if its been more then 15 days between the 2 then it will suspend. but not sure how to get it working. I am close i think.
<?php
$s = mysql_query("SELECT * FROM user WHERE id='2'") or die(mysql_error());
$info = mysql_fetch_array($s, MYSQL_ASSOC);
@mysql_free_result($s);
if ($info['joindate']) < = date("m-d-Y", 30*86400 + time());
(query here to update account to suspened)
}
?>
hope somone can give me a lil more insight as i am still lost some
Thanks
Date comparision
Moderator: General Moderators
Re: Date comparision
you can do with query itself.
you can get only 15 days passed person with following guery
SELECT * FROM user WHERE joindate > DATE_SUB(curdate(),INTERVAL 15 days)
or
SELECT *,IF(joindate > DATE_SUB(curdate(),INTERVAL 15 days),'YES','NO') AS exp FROM user WHERE id=2
$info['exp'] will give you 'YES' if that passed 15 days....
you can get only 15 days passed person with following guery
SELECT * FROM user WHERE joindate > DATE_SUB(curdate(),INTERVAL 15 days)
or
SELECT *,IF(joindate > DATE_SUB(curdate(),INTERVAL 15 days),'YES','NO') AS exp FROM user WHERE id=2
$info['exp'] will give you 'YES' if that passed 15 days....
Re: Date comparision
Thanks I will give that a try
Re: Date comparision
You can also use the DATEDIFF function in your SQL:
if you want to update the "user" table then you can use the following SQL query:
Code: Select all
SELECT * FROM user WHERE DATEDIFF(now(),joindate)>15Code: Select all
UPDATE user SET suspend=1 WHERE DATEDIFF(now(),joindate)>15