Page 1 of 1

Help with MYSQL datediff

Posted: Wed May 12, 2010 6:02 pm
by echofool
Hey im trying to make my query return how many seconds have passed from a time stamp to NOW() but i cannot get it to work, this is what i tried:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'User1Time) AS User1Passed,SECOND(NOW()User2Time) AS User2Passed FROM' at line 1
SQL:

Code: Select all

SELECT 
*,SECOND(NOW(),User1Time) AS User1Passed,SECOND(NOW(),User2Time) AS User2Passed 
FROM tablename()
Any one know where i went wrong ?

Hope you can help thanks!

Re: Help with MYSQL datediff

Posted: Wed May 12, 2010 9:36 pm
by califdon
You need to find the difference between 2 times, right? For that you have to use TimeDiff() function, not Seconds(). Check out these functions in the SQL Manual.

Re: Help with MYSQL datediff

Posted: Thu May 13, 2010 1:00 pm
by echofool
Thanks it works now :)