|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
I have a table with a TIMESTAMP entry, and I would like to find a
query that will look at this table and only return results that shows the TIMESTAMP to be five minutes ago or less. Something along these lines: SELECT * FROM table_name WHERE entry_date BETWEEN NOW() AND NOW()-5 minutes ago entry_date is a full timestamp any appreciated, AN |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
andrecal wrote:
> I have a table with a TIMESTAMP entry, and I would like to find a > query that will look at this table and only return results that shows > the TIMESTAMP to be five minutes ago or less. > > Something along these lines: > SELECT * FROM table_name WHERE entry_date BETWEEN NOW() AND NOW()-5 > minutes ago > > entry_date is a full timestamp > > any appreciated, > AN Hmm, you say "any appreciated", yet you have completely ignored the superb given by the developers when they wrote the section "Date and Time Functions" in the MySQL user manual (http://dev.mysql.com/doc/refman/5.0/...functions.html)! I just went there to find the answer. SELECT * FROM table_name WHERE entry_date > date_sub( now( ) , INTERVAL 5 MINUTE ) or you may prefer: SELECT * FROM table_name WHERE entry_date > now( ) - INTERVAL 5 MINUTE |
|
![]() |
| Outils de la discussion | |
|
|