How do I difference time in MySQL query?

There's a datetime field "time" and it's in Y-m-d H:i:s format. All the values are past values. I need to query that field diffed from current time resulting in seconds.

SELECT time FROM table
This question and answers originated from www.stackoverflow.com
Question by (11/4/2011 4:43:07 PM)

Answer

SELECT TIME_TO_SEC(TIMEDIFF(now(),time)) AS time FROM myTable;
Answer by

Find More Answers
Related Topics  mysql  database  query  time
Related Questions
  • How do I do this query in MySQL? (datetime)

    Suppose I have a datetime column in MySQL. How do I select all that have a datetime within 2500 seconds of the current datetime? SELECT ALL where current_datetime - that_datetime < 2500 ...
  • How do I write this GROUP BY query in MYSQL?

    Suppose I have a column called "fruits" I want to select all of the top fruits, ranked by fruits (and group by + count). Fruits: orange orange apple banana apple apple In this case, the selec…
  • How do I modify this query in MYSQL?

    SELECT title, title REGEXP 'apple' as is_fruit FROM mytable; TO: SELECT title, title REGEXP 'apple' or orange...or grapes...as is_fruit... Basically, how do I do an "OR" for REGEXP?
  • How do I execute this query in MYSQL?

    Suppose I have a column with words: orange grape orange orange apple orange grape banana How do I execute a query to get the top 10 words, as well as their count?
  • How do I query "begin with" in MySQL?

    SELECT stuff REGEXP 'itunes' as is_itunes; In this MySQL query, if "stuff" has the word "itunes" in it, it will mark it as itunes. However, I want to say "begin with". How can I check for "be…
  • How can i do the sumation of time in mysql query?

    I have a table like this : And in this table you can see the last column totalloginFinal, I want to do the sum of all time, its will be about 84 hours, I am trying with addtime and sum fun…
  • Query time result in MySQL w/ PHP

    Is there a way that I can get the time of a MySQL query (specifically with PHP)? The actual time it took to complete the query, that is. Something such as: Results 1 - 10 for brown. (0.11 seconds…
  • How do I execute this GROUP BY mysql query?

    Suppose I have a table called "Fruits" with a column called "name". name -------- apple orange orange orange apple grape How can I execute a query to produce this: orange 3 apple 2 grape…
  • How do I run this MySQL JOIN query?

    Let's say I have 2 tables. The first table is a list of personas. A user can have many personas. mysql> select id, user_id, name from personas_personas; +----+---------+--------------+ | id…
  • MySql query execution time

    I am using MySQL Workbench on Windows. How do I find out the time taken to execute a query like Select * from employers where employerid > 200 Is there a statement I can enter that returns…