Rick
asked on
MySql 5.1 - Show time difference between two columns
Hello,
How do I write a SELECT statement to show the time difference between two columns.
I want to show the difference in Double type, not in Time.
How do I write a SELECT statement to show the time difference between two columns.
I want to show the difference in Double type, not in Time.
Example:
StartTime EndTime
08:30:00 10:00:00
I want to show the result as 1.5, not 01:30:00
Thanks,
Rick
select hour(timediff(EndTime, StartTime)), round(minute(timediff(EndT ime, StartTime))/60, 1);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
gregfortune,
That's really good. Thanks.
I will accept your answer, I just have one question though, what's the "1" at the end of the query?
Thanks,
Rick
That's really good. Thanks.
I will accept your answer, I just have one question though, what's the "1" at the end of the query?
Thanks,
Rick
For example, 1 means 45.923 = 45.9
Yup, as suredazzle stated, round takes two arguments. The first argument is the number to round and the second argument is the "precision" or number of digits after the dot. If you want two digits (ie, 123.01), change it from 1 to 2.
ASKER
Thanks