Reputation:
For example, I have 2 dates
$start = 2020-08-15 20:39:43;
$end = 2020-08-15 20:59:43;
$total = $end - $start = 10 min;
how can I do that?
Upvotes: 0
Views: 40
Reputation: 222462
Use timestampdiff()
:
select timestampdiff(
minute,
'2020-08-15 20:39:43',
'2020-08-15 20:59:43'
)
If your dates are in columns start_ts
and end_ts
of table mytable
, then:
select timestampdiff(minute, start_ts, end_ts) diff_minutes
from mytable
Upvotes: 2