I have column that keep current date (DATE in mysql) when insert record.
How to select record that post within 3 days.
| SitePoint Sponsor |


I have column that keep current date (DATE in mysql) when insert record.
How to select record that post within 3 days.
I live in Thailand. My English grammar not well.
Select * from mytable where date=$three_days_ago;PHP Code:$three_days_ago = gmdate("Ymd") - 3;
Actually, that might be a bit crap because you need the "-" in the date... I have to go, so I cant give you the extra code right now.. sorry! (Doh!)
Last edited by infoxicated; Jun 19, 2002 at 10:25.


SELECT blah, blah_blah FROM table WHERE TO_DAYS(NOW()) - TO_DAYS(date-or-timestamp_col) <= 3;
cd pub \r; more beer
![]()
Eddie


Thanks, Is TO_DAYS() is function in mysql.
It seem doesn't work.![]()
I live in Thailand. My English grammar not well.



TO_DAYS() is a MySQL function. It returns a day number given a date.
Exactly what query are you trying?
It looks to me like the SQL eddiembabaali posted should work fine.


I'm write wrong code. but now it work.
Thanks everybody again.![]()
![]()
I live in Thailand. My English grammar not well.
Bookmarks