473,657 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with select statement where time <= 5min ago

Hi, i need some help with a select statement, i tried many different
MySQL fucntions and looked through the MySQL manual, and it didnt help
me any. What i want to do is select all rows from a table where my
time column(DATETIME ) is less then or equal to 5 minutes ago from
now().

Any help is appreciated, thanks
Jul 20 '05 #1
1 6422
FuRiOuS1 wrote:
Hi, i need some help with a select statement, i tried many different
MySQL fucntions and looked through the MySQL manual, and it didnt help
me any. What i want to do is select all rows from a table where my
time column(DATETIME ) is less then or equal to 5 minutes ago from
now().


# this will get you date_time 5 minutes ago
select DATE_SUB( now(), INTERVAL 5 MINUTE );

You can use <, >, =, >= or <= operators with dates also. So you can
compare the date in your table like this:

select * from table
where datetimefield <= DATE_SUB( now(), INTERVAL 5 MINUTE );

Read this page if you need more info about date and time functions:
http://dev.mysql.com/doc/mysql/en/Da...functions.html
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3507
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value in a list box and submits the form the value is put into a session variable and the relevant page is displayed (in accordance to one of the list boxes). The page is then displayed with the relevant SQL data. So far i have got the
0
1728
by: Jorge Pinto | last post by:
Hello Folks, Please I need a help !!! Has anyone tried to save the returning of a select statement in the message body of the email ?? How did you do that !!! I'm having a hard time to do that. I got the select statement but the problem is how to save it in the message body...... Thanks in advance, JP
0
372
by: FuRiOuS1 | last post by:
Hi, i need some help with a select statement, i tried many different MySQL fucntions and looked through the MySQL manual, and it didnt help me any. What i want to do is select all rows from a table where my time column(DATETIME) is less then or equal to 5 minutes ago from now(). Any help is appreciated, thanks
2
2464
by: ghasem | last post by:
Dear mySQL community, I have once again turned to the user groups for a problem I cannot solve myself! Atually, I have read all I can from the newsgroups on this but I could not solve it myself. Here it is: mySQL server: version "4.0.20-standard" on localhost hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and 40 MB Matrox+ harddisk Here is the problem:
1
11108
by: avinash | last post by:
hi myself avi i am developing one appliacaion in which i am using vb 6 as front end, adodb as database library and sql sever 7 as backend. i want to update one table for which i required data from other table. and iretrive data from second table by giving some condition. when i get data, then to update first table i need to use do while loop. instead of that i want to use select statement directly in update query. plz give me some help....
2
1578
by: GIS Analyst | last post by:
Hi to all I wish to be able to have a standard select statement which has additional fields added to it at run-time based on supplied parameter(s). ie declare @theTest1 nvarchar(10) set @theTest1='TRUE'
15
2732
by: grunar | last post by:
After some thought on what I need in a Python ORM (multiple primary keys, complex joins, case statements etc.), and after having built these libraries for other un-named languages, I decided to start at the bottom. What seems to plague many ORM systems is the syntactic confusion and string-manipulation required to build the SQL Statements. If you want to do a Left Outer Join, support nested functions, and a nested conditional clause, you'd...
8
1461
by: flamesrock | last post by:
So, I was blazin' some mad chronix, as they say, and got on to thinking about Python. The question was, is the statement: time.time() < time.time() always true? Seems it should be false, since the statement itself occurs at one time instant.. but of course we know that python doesn't execute code that way.. So my question is, why doesn't Python work this
1
3689
by: ncsthbell | last post by:
Once again... I am supporting another Access database that I did not build. The previous 'owner' of this built the tables with spaces in the table names as well as the column names. I am having a difficult time getting the select statement to work. I am getting a run-time error 2342. "A RunSql action requires and arguement consisting fo an SQL statement. I am using MS Access 2007. Behind a command button on a form I am building code to...
0
8305
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,...
0
8726
jinu1996
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...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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...
1
2726
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
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.