Solved

SQL - How to decrease decimal places (or remove the extra zero's at the end)

Posted on 2008-10-29
1
1,082 Views
Last Modified: 2012-08-14
I have a table1 that saves the duration for a trip. table1 contains the following columns:
hourStart
hourEnd
minuteStart
minuteEnd

To calculate the duration of the trip, I am using the following query:
select ((hourEnd-hourStart) + ((cast((minuteEnd-minuteStart) as decimal))/60)) as trip  from table1

This works, except the results have too many zero's at the end:
1.500000

I want to format this as followed:
1.50

Is there a way to decrease the decimal places (or remove the extra zero's at the end)?
0
Comment
Question by:fippif
1 Comment
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 22833516
select cast(value as decimal(18,2))
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now