...

View Full Version : Query Date/Time Question



angst
07-21-2006, 02:16 AM
hello,
I'm trying to query users that have been on the site in the last 15 minutes from a date time feild in a mysql data base.

I can do this already with php code, but would like to do it right from the select statement, but i'm not exactly sure how or where to start.

any ideas/examples would be great!

thanks in advance for your time,
-Ken

Fumigator
07-21-2006, 02:29 AM
You can use the date_sub function, like this:



$query = "
SELECT *
FROM your_table
WHERE your_timestamp > date_sub(CURRENT_TIMESTAMP , INTERVAL 15 MINUTE)


This code says get all rows with a timestamp greater than this moment minus 15 minutes.

angst
07-21-2006, 02:37 AM
kool!
thats what i was looking for:thumbsup:

thanks!
-Ken



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum