Page 1 of 1

dates diff in mysql query

Posted: Mon Mar 01, 2004 11:30 am
by yaron
Hello all,

I have a table which one of it's fields is a timestamp.
I want to select from this table only the records from the last 15 minutes.
I.E. get the system time and compare it to the time stamp in the specific field. if the differnce is less than 15 mins (or any other anount of minutes that i will set up) select the row.

I'm sure it's possible to do in a query and I don't have to get all rows and check in a php script, but I don't now quite how to achive that.

Any ideas?

Posted: Mon Mar 01, 2004 12:26 pm
by Weirdan

Code: Select all

select something from somewhere where dateinsert>now()-interval 15 minute
look mysql manual for now and interval

Posted: Mon Mar 01, 2004 12:34 pm
by yaron
thanks,
I'll try this one :)