Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    32

    Unanswered: 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.

  2. #2
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •