开发者

How to calculate elapsed time in terms of minutes in MySQL

There is a time stamp column/field i开发者_如何转开发n a table, and the format is like

2009-12-05 10:35:28,

Now I want to get the time in terms of minutes(How many minutes have elapsed) elapsed from then on, how to do it?


TIMEDIFF() can be used to get a difference between date/time values, which is expressed in a "HH:MM:SS.SSSSSS" format.

TIME_TO_SEC() can convert this into a number of seconds.

SELECT TIME_TO_SEC(TIMEDIFF(NOW(), my_date_and_timestamp)) / 60;


SELECT TIMESTAMPDIFF(MINUTE,your_timestamp_column_name,NOW()) AS minutes_elapsed FROM your_table_name WHERE your_criteria
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜