Help with MYSQL datediff

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
echofool
Forum Newbie
Posts: 16
Joined: Mon Mar 22, 2010 1:15 pm

Help with MYSQL datediff

Post 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!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with MYSQL datediff

Post 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.
echofool
Forum Newbie
Posts: 16
Joined: Mon Mar 22, 2010 1:15 pm

Re: Help with MYSQL datediff

Post by echofool »

Thanks it works now :)
Post Reply