473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Selecting record edited within last 2 minuites

20
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 1633
Markus
6,050 Expert 4TB
@USBZ0r
Are you using mysql's timestamp? Or what kind of time stamp are you using?
Apr 10 '09 #2
USBZ0r
20
TimeStamp yes

Thanks for reply.
Apr 10 '09 #3
Markus
6,050 Expert 4TB
@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
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 Expert 4TB
@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
Thanks mark, il give that a try!
Apr 10 '09 #7
Markus
6,050 Expert 4TB
@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
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...
4
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...
5
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....
8
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...
5
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...
22
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....
9
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...
4
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
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...

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.