Space Cowboy Posted March 25, 2006 Share Posted March 25, 2006 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 format20060324003725Cheers! Quote Link to comment Share on other sites More sharing options...
toplay Posted March 25, 2006 Share Posted March 25, 2006 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_nameSee 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.