Solved

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

Posted on 2008-10-29
1
1,089 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

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

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

690 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