Hi,
I've got a transactions table with a tstamp field (datetime type) and
I need help creating a SELECT query to retrieve only last transactions
that occured within the last 5 minutes. The datetime type writes the
tstamp as YYYY-MM-DD HH-MM-SS and I am using mySQL 4.1.
Please help. 4 3677
Neeper wrote: Hi,
I've got a transactions table with a tstamp field (datetime type) and I need help creating a SELECT query to retrieve only last transactions that occured within the last 5 minutes. The datetime type writes the tstamp as YYYY-MM-DD HH-MM-SS and I am using mySQL 4.1.
Please help.
Neeper,
Calculate the start time in the program which calls your MySQL
query and pass it in as a parameter.
For example in PHP you would have a statement something like:
$starttime = time() - 300;
and would then use in the call to your retrieval program/function.
retrieve_functi on($starttime);
Where:
time() if the PHP function that returns the current time
of day.
300 is the number of seconds in 5 minutes.
HTH
Jerry
Is there anyway of just using a straight mySQL statement without any
PHP manipulation?
On Sun, 24 Apr 2005 12:36:04 GMT, jerry gitomer <jg******@veriz on.net>
wrote: Neeper wrote: Hi,
I've got a transactions table with a tstamp field (datetime type) and I need help creating a SELECT query to retrieve only last transactions that occured within the last 5 minutes. The datetime type writes the tstamp as YYYY-MM-DD HH-MM-SS and I am using mySQL 4.1.
Please help. Neeper,
Calculate the start time in the program which calls your MySQL query and pass it in as a parameter.
For example in PHP you would have a statement something like:
$starttime = time() - 300;
and would then use in the call to your retrieval program/function.
retrieve_functi on($starttime);
Where: time() if the PHP function that returns the current time of day.
300 is the number of seconds in 5 minutes. HTH Jerry
On 25/04/2005, Neeper wrote: Neeper wrote:
I've got a transactions table with a tstamp field (datetime type) and I need help creating a SELECT query to retrieve only last transactions that occured within the last 5 minutes. The datetime type writes the tstamp as YYYY-MM-DD HH-MM-SS and I am using mySQL 4.1.
Is there anyway of just using a straight mySQL statement without any PHP manipulation?
USE TEST;
DROP TABLE IF EXISTS foo;
CREATE TABLE foo
(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ts DATETIME);
SELECT id FROM foo WHERE DATE_SUB(NOW(), INTERVAL 5 MINUTE) < ts;
--
felix
Thank you felix.
On Mon, 25 Apr 2005 10:55:58 GMT, "Felix Geerinckx"
<fe************ *@gmail.com> wrote: On 25/04/2005, Neeper wrote:
Neeper wrote:
I've got a transactions table with a tstamp field (datetime type) and I need help creating a SELECT query to retrieve only last transactions that occured within the last 5 minutes. The datetime type writes the tstamp as YYYY-MM-DD HH-MM-SS and I am using mySQL 4.1.
Is there anyway of just using a straight mySQL statement without any PHP manipulation?
USE TEST; DROP TABLE IF EXISTS foo; CREATE TABLE foo (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ts DATETIME);
SELECT id FROM foo WHERE DATE_SUB(NOW(), INTERVAL 5 MINUTE) < ts; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my predecessor, I hasten to add) so that each day it creates a
copy of the record for each company, changes the date to today's date,
and prompts the user for any changes of ratings on that day. The
resulting data table grows by approx 600 records per...
|
by: prabhukalyan |
last post by:
Hi all,
I am not so good in queries. here is my problem
2 tables to store the received items (fabric)-- inwardmaster,
inwarddetails
and after some processing (Dyeing)
the items were deliverd and stored in tables -- deliverymaster,
deliverydetails
|
by: Rahul |
last post by:
Hi Everybody
I have some problem in my script. please help me. This is script file.
I have one *.inq file. I want run this script in XML files. But this
script errors shows . If u want i am attach this script
files and inq files. I cant understand this error. Please suggest me.
You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online.
Plz....Plz..Plz...
|
by: Dynamo |
last post by:
Hi again,
I am constructing a site on a small scale where people can buy nik naks and pay
for them via paypal. Everything works fine unless there is only one of an item
left for sale. What if 2 people try to buy this item at the same time?
I have partially overcome this problem by adding an extra column called status
to my catalogue table. When somebody tries to buy the item I have created an
interim page where the user is asked to confirm...
| |
by: Siv |
last post by:
Hi,
I have a stored procedure that I want to execute and then wait in a loop
showing a timer whilst it completes and then carry on once I get
notification that it has completed. The main reason for this being to stop
the user thinking the application has frozen when in fact it is just waiting
for a long SP to complete. Another reason for doing it like this is that I
also have had a problem in the past where the SP takes longer than the...
|
by: dan |
last post by:
within a loop i am building a sql insert statement to run against my
(programatically created) mdb. it works but it seems unreasonably SLOW!
Sorry, dont have the code here but the jist is very standard (I
think!);
e.g:
# get connection
loop
|
by: Sam |
last post by:
Hi,
I have one table like :
MyTable {field1, field2, startdate, enddate}
I want to have the count of field1 between startdate and enddate, and
the count of field2 where field2 = 1 between startdate and enddate,
all in the same query.
|
by: gnawz |
last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |