If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > find seconds ago on multi row query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-09, 00:16
ameyer ameyer is offline
Registered User
 
Join Date: Jul 2009
Posts: 32
find seconds ago on multi row query

I want to do a query that will return multiple rows (each has a timestamp) and show how many seconds ago that was.

I know how to do it for a single row selection
SELECT TIME_TO_SEC(TIMEDIFF(NOW(), record_timeStamp)) AS ago FROM records WHERE record_id = 12


but im looking more for SELECT TIME_TO_SEC(TIMEDIFF(NOW(), record_timeStamp)) AS ago FROM records so it will output all of them.

When I try this, the "ago" returns with the same value for all of them. I 80% understand why. But dont know how to fix that.
Reply With Quote
  #2 (permalink)  
Old 11-11-09, 00:48
ameyer ameyer is offline
Registered User
 
Join Date: Jul 2009
Posts: 32
This does seem to work though:

SELECT TIME_TO_SEC(record_timeStamp) - TIME_TO_SEC(NOW()) AS ago FROM records

Is there a better/ faster way? Or is this correct?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On