MySql 5.1 - Show time difference between two columns


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

Open in new window

LVL 13
Who is Participating?

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

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.

select hour(timediff(EndTime, StartTime)), round(minute(timediff(EndTime, StartTime))/60, 1);
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)

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:

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?

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


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.
RickAuthor Commented:
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.