Jump to content


This topic is now archived and is closed to further replies.

Space Cowboy

time difference between 2 time stamps

Recommended Posts

Hi,im looking for a simple bit of code that will get me the difference in MINUTES between 2 time stamps.
The time/date stamps in the database are in this format



Share this post

Link to post
Share on other sites
You didn't mention what version of MySQL you're using (or even if that's what you're using).

Anyway, you should be able to simply subtract one TS column from the other and multiply by 60 to give you the minutes you want.

An alternative is to use the UNIX_TIMESTAMP() function:

SELECT UNIX_TIMESTAMP(date1_column) - UNIX_TIMESTAMP(date2_column) * 60 AS diff_in_minutes FROM table_name

See this for more info:

[a href=\"http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#id3206258\" target=\"_blank\"]http://dev.mysql.com/doc/refman/4.1/en/dat....html#id3206258[/a]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.