What replaces the italicized junk in this statement?
Code:SELECT * FROM messages WHERE date is 30 days old or more
Printable View
What replaces the italicized junk in this statement?
Code:SELECT * FROM messages WHERE date is 30 days old or more
depends on the format of date in your table
TIMESTAMP(14)
Bumptety bump bump...
uhhggg I hate timestamps. makes things more difficult to chekc like you are doing.
you could try to compare it to the current timestamp on the box. this is one way of doing it.
PHP Code:// this will get the current time form the server and then make it
//so it looks 30 days old. then you will need to get the timestamp
// form the DB and convert it as well.
$dy = date("d");
$mn = date("m");
$yr = date("Y");
$lat = 30;
$expiredate = strftime("%Y.%m.%d", mktime(0,0,0,$mn,$dy-$lat,$yr));
//then after you get the time form the DB and convert it
// you can compare the 2, if equal then you do what you wanted to.
Timestamps are excellent for the project I'm working on though.
And cheeky monkey, will try that :)
have you tried the range thing in SQL...
SELECT whatever from tblWhatever where tblWhatever.orderdate > '$fromyear-$frommonth-$fromday 00:00:00' and customerinfo.orderdate < '$tooyear-$toomonth-$tooday 23:59:59'
fromyear, frommonth and fromday are just passed through a select box on the previous page but you could just capture today and add 30. Or am I totally off of what you're trying to do.
:eek: Way off. This worked:
Code:SELECT * FROM messages WHERE date<NOW() - INTERVAL 30 DAY