Page 1 of 1

Fetch difference between two timestamps in seconds

Posted: Wed Feb 14, 2007 4:08 pm
by Darla
Hello

I have a database table where each record has a timestamp (created using the NOW() function perhaps CURRENT_TIMESTAMP is more correct to use?)

I wish to make a simple query which compare timestamp of right now with the timestamp in the database and returns the difference in seconds.

Is there some easy way to do this?

Darla

Posted: Wed Feb 14, 2007 4:22 pm
by onion2k

Code: Select all

select (UNIX_TIMESTAMP(NOW())-myTimestamp) as difference from myTable
Maybe. I've not tried it.

Posted: Wed Feb 14, 2007 4:43 pm
by Darla
Thanks, I'll try it out but am having some problems with my server now :(