hi,
i have a mysql db where i got a timestamp field.
No i want to make a mysql query where he gives me the rows where the timestamp is between now and 30minutes ago.
I dont have many date mysql experiences, so any help would be great.
the timestamp is in the following format:
2006-12-16 18:24:36
thanx
date now minus 30 minutes in mysql
Moderator: General Moderators
Happy reading: http://dev.mysql.com/doc/mysql/en/date- ... tions.html.
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
You'd be best working with Unix timestamps for this.
Insert the date into the MySQL DB as a Unix timestamp using.
You can then run the query:
I assume there a way to do that without using PHP. But that's the first idea that hit my head.
Hope that helps, Stephen
Insert the date into the MySQL DB as a Unix timestamp using
Code: Select all
mktimeYou can then run the query:
Code: Select all
$now = time();
$earlier = time - 1800;Code: Select all
SELECT *
FROM somewhere
WHERE date < '$time'
AND date > '$earlier'
Hope that helps, Stephen
According to
that would betimvw wrote:Happy reading: http://dev.mysql.com/doc/mysql/en/date- ... tions.html.
Code: Select all
SELECT
x,y,z
FROM
abc
WHERE
datefield BETWEEN Now() AND Now()-Interval 30 minute