Thursday, January 6, 2011

Finding time difference in seconds between 2 dates ( timestamps )


In my situation i needed query to find time difference in seconds between current time and field's value.
SELECT TIME_TO_SEC(TIMEDIFF(NOW(),`field_name`));
between 2 mysql fields can look like this:
 SELECT TIME_TO_SEC(TIMEDIFF(`field_name1`,`field_name2`));

No comments:

Post a Comment