Solved

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

Posted on 2008-10-29
1
1,085 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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

685 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