-1
Proc Id       Start_time             end_time                Status
111           7/4/2017 9:08:43 AM    7/4/2017 9:35:54 AM     Success

I want to find the time duration(in Mins) between the star_time and end_time. Please help me how to do it?

Giorgos Betsos
  • 71,379
  • 9
  • 63
  • 98
  • https://stackoverflow.com/questions/4759248/difference-between-two-dates-in-mysql This may help you. – YLG Jul 04 '17 at 08:55
  • Store dates/times correctly. – Strawberry Jul 04 '17 at 09:07
  • You can of course work around these string with str_to_date, in order to convert some string to a datetime, but why not store your moments as a DATETIME? In your setup you will always have to convert your strings whenever you need to compare it to something. That will never be a speedy query when many records are involved – Ivo P Jul 04 '17 at 10:15

2 Answers2

0

You can try with this one...

SELECT TIMESTAMPDIFF(MINUTE,tmp.start_time,tmp.end_time) FROM (select start_time,end_time from table_name where id=?) as tmp;
Amit Contractor
  • 169
  • 3
  • 3
0
SELECT TIMESTAMPDIFF(MINUTE,STR_TO_DATE(Start_time,'%d/%m/%Y %H:%i:%s),STR_TO_DATE(end_time,'%d/%m/%Y %H:%i:%s)) from TABLENAME;

Try above query.Hope this will help you.

Sagar Gangwal
  • 7,544
  • 3
  • 24
  • 38