473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting record edited within last 2 minuites

20 New Member
Hi there guys!

Im struggling to find a way to select all rows from a MySQL table that were edited within the last 2 minuites. When the user edits their profile, it time stamps it. So all i need to do is fetch all rows that were time stamped within the last 2 minuites of the current time.

anyone have any ideas how it would be done in PHP/SQL?

Thanks
Apr 10 '09 #1
7 1650
Markus
6,050 Recognized Expert Expert
@USBZ0r
Are you using mysql's timestamp? Or what kind of time stamp are you using?
Apr 10 '09 #2
USBZ0r
20 New Member
TimeStamp yes

Thanks for reply.
Apr 10 '09 #3
Markus
6,050 Recognized Expert Expert
@USBZ0r
Ok, so the way that makes sense to me is to convert your timestamp into seconds using UNIX_TIMESTAMP( column ) and then use TIMEDIFF against current UNIX_TIMESTAMP( ) (note: no argument given).

Something like below:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.   *
  3. FROM
  4.   `tbl_name`
  5. WHERE
  6.   TIMEDIFF
  7.   (
  8.     UNIX_TIMESTAMP(),
  9.     UNIX_TIMESTAMP( `tmestmp_clmn` )
  10.   ) < 121
Does that make sense?
Apr 10 '09 #4
USBZ0r
20 New Member
thanks!

kinda does yeah, but is TimeDIF PHP or MySQL valid? and i take it tmestmp_clmn would be where the time stamp in my database gets put?
Apr 10 '09 #5
Markus
6,050 Recognized Expert Expert
@USBZ0r
UNIX_TIMESTAMP( ) and DATEDIFF() are MySQL functions. They can be used in your SQL queries.

Expand|Select|Wrap|Line Numbers
  1. $query = "
  2. SELECT
  3.   ...
  4.   ...
  5.   DATEDIFF( ... )";
  6.  
Yep, you will have to rename the columns to reflect your table set up.
Apr 10 '09 #6
USBZ0r
20 New Member
Thanks mark, il give that a try!
Apr 10 '09 #7
Markus
6,050 Recognized Expert Expert
@USBZ0r
Let us know if you have any problems or questions.

- mark.
Apr 10 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5124
by: Ryan | last post by:
I have a problem with record locking / blocking within an application. The app is quite straight forward. Written in Delphi 5 using BDE to access a SQL 7 database (Win2K server). Every so often the users (when they bother to tell me) find that the application locks up and they are unable to work. No errors are produced (error trapping in the app is good). They 'shout round' to each other and get someone to exit the data entry screen....
4
2945
by: Lucius | last post by:
Hello everyone, I have a query problem. I'll put it like this. There is a 'publishers' table, and there is a 'titles' table. Publishers publish titles (of course). Now I want to make a query (in MS SQL Server) that would return the last title published by every of the publishers. Quite clear situation. But I can't make it work. If I use inner join (which I should, because I need data from both tables) then I get a result showing all...
5
7315
by: uthuras | last post by:
Machine : AIX 5.2 Product : UDB DB2 Release 8.1 FP4a I have problem loading data into destination table. The data file is huge with more than 6 Million records. This what i have done 1. Export the data into flat file (del format) 2. use the load command to load the data At step 2, i found that there are some errors registered in the load
8
3306
by: Mark | last post by:
When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same data in many of the fields so I paste in the same values of the previous record and then edit what needs edited in the new record saving much retyping of the same data. Doing this however creates the definite possibility of creating a duplicate...
5
2227
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table (tbl_MainRegister) providing a unique identifier for documents and a means for identifying the docuement type. There are then 4 additional tables (tbl_Meetings, tbl_Documents, tbl_Project, tbl_Correspondence) which store the document details.
22
18814
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4. The system is client/server, multiusers based. The MDBs are using record locking. Here is part of the code: Dim wkSpace As Workspace, db As Database Dim rstTrans As DAO.Recordset Set wkSpace = DBEngine.Workspaces(0)
9
2480
by: =?Utf-8?B?UHJhdmlu?= | last post by:
We are using .net Framework 1.1 We are having one page on which we are using this Grid component. From this page we open a popup for adding new record as well as for editing an existing record (For Edit we want to pass the ID of that particular row) And when user clicks on 'SAVE' button in popup window, those changes need to be reflected onto the parent (into the Grid). This happens by refreshing the parent page. But in that case all...
4
1816
by: SoulSeeker | last post by:
Hello. How I can start my M$ access form with last edited record? What I must put in "on load" field? Tnx. for advice.
19
4030
by: emanning | last post by:
Using Access 2003 and using a form that's mostly bound. I need a way to tell if user-1 is on the record when user-2 tries to open the same record, w/o waiting for the user-1 to save the record first. The only way I can think of is by adding a flag to the record and setting it to true when user-1 opens the record. If user-2 tries to open it, the flag is checked for true, then a message would be displayed to them that user-1 is on the...
0
9643
marktang
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...
0
9480
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
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9947
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
8971
agi2029
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...
0
6737
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
5380
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
4046
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.