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.
Example:
 
StartTime      EndTime
 
08:30:00       10:00:00
 
 
I want to show the result as 1.5, not 01:30:00
 
 
Thanks,
Rick

Open in new window

LVL 13
RickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gregfortuneCommented:
select hour(timediff(EndTime, StartTime)), round(minute(timediff(EndTime, StartTime))/60, 1);
0
gregfortuneCommented:
Hmm, guess I can't edit my first post.  If you want that as a single value, you'd just add the two results together.

For example,

hour(timediff(EndTime, StartTime)) + round(minute(timediff(EndTime, StartTime))/60, 1)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RickAuthor Commented:
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
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

suredazzleCommented:


For example, 1 means 45.923 = 45.9
0
gregfortuneCommented:
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.
0
RickAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.