计算同一表中一列中日期之间的差异

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算同一表中一列中日期之间的差异相关的知识,希望对你有一定的参考价值。

I use something similar to the example to get the difference between statuses in a status log table that I have. It comes in handy when determining the number of days between status changes. This works in mysql 5.0.
  1. (SELECT DATE(date_field) FROM table WHERE id = '1' AND status_id = '2' ORDER BY date_field DESC LIMIT 1),
  2. (SELECT DATE(date_field) FROM table WHERE id = '1' AND status_id = '1' ORDER BY date_field DESC LIMIT 1)

以上是关于计算同一表中一列中日期之间的差异的主要内容,如果未能解决你的问题,请参考以下文章