Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to determine difference between two time stamps

Status
Not open for further replies.

andnos

Technical User
Nov 21, 2005
48
US
I have two fields in a table

timestart
timestop

and they have values such as

2006-05-11 12:07:18
2006-05-11 12:22:56

How to make a query that'll extract out the days/hours/minutes/seconds differences between the two dates?

Any help would be appreciated.
 
I think you can just use the TIMEDIFF function. From the manual

TIMEDIFF(expr,expr2)
TIMEDIFF() returns the time between the start time expr and the end time expr2. expr and expr2 are time or date-and-time expressions, but both must be of the same type.
mysql> SELECT TIMEDIFF('2000:01:01 00:00:00',
-> '2000:01:01 00:00:00.000001');
-> '-00:00:00.000001'
mysql> SELECT TIMEDIFF('1997-12-31 23:59:59.000001',
-> '1997-12-30 01:01:01.000002');
-> '46:58:57.999999'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top