so i have a table with a date column. i have scripts that wuold insert now() into that column whenever processed. so the format would be yyyy-mm-dd in the table. does anyone know how form a query to select the records with the (date column + x days) to it?
omoutop
11:48 am on Jul 30, 2007 (gmt 0)
not sure, but you may try the BETWEEN suntax
"select * from table where date_field between x and y", where x,y your date ranges.
I guess there must be another more convinient way
distorto
2:35 pm on Jul 30, 2007 (gmt 0)
I don't know if this will help, but here's a sql statement that deletes rows from a collumn called 'messages' where the 'date' is more than one day ago.
DELETE FROM `messages` WHERE date < NOW() - INTERVAL 1 DAY
ps - I had troubles with these until I set the mysql data type for 'date' to timestamp. That's what NOW() produces.
d40sithui
5:48 pm on Jul 30, 2007 (gmt 0)
yea i tried that, it does work but um, i need something for 3 days. I guess i can use the strtotime() function, convert now() and whatever's in the db into numbers that i can work with..but thatll a few more queries, assuming it works. =/
distorto
5:55 pm on Jul 30, 2007 (gmt 0)
INTERVAL 3 DAY
d40sithui
5:57 pm on Jul 30, 2007 (gmt 0)
oh lol thought that was a comment
jamie
5:58 pm on Jul 30, 2007 (gmt 0)
don't know if this may be the problem, but remember to enclose the yyy-mm-dd field in the query in quotes
select * from table where date between '20007-07-01' and '20007-08-01'