Hi all...
So, I am needing to sum all billable hours within a table... the problem is that it is returning rouded decimals instead... like .5 always comes back as 1 ...

Here is my procedure:

Public Shared Function GetBillableTimeForTicket(ByVal SupportTicketID As Integer) As Decimal
        Dim conn As New SqlConnection(GetConnectionString("ClientPortal.My.MySettings.conString"))
        Dim sP As String = "GetBillableTimeForTicket"
        Dim cmd As New SqlCommand()
        cmd.Parameters.Clear()
        cmd.CommandText = sP
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.AddWithValue("@SupportTicketID", SupportTicketID)
        Dim parameter1 As New SqlParameter("@TotalBillableTime", SqlDbType.Decimal)
        parameter1.Direction = ParameterDirection.Output
        cmd.Parameters.Add(parameter1)
        cmd.Connection = conn
        Try
            HandleConnection(conn)
            cmd.ExecuteNonQuery()
            Try
                Dim totalBillableTime As Decimal = Decimal.Parse(cmd.Parameters("@TotalBillableTime").Value.ToString())
                Return totalBillableTime
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            HandleConnection(conn)
        End Try
    End Function

And here is my StoredProcedure... I have tried so many variations of this SUM... Here is my latest...

ALTER PROCEDURE dbo.GetBillableTimeForTicket
	(
	@SupportTicketID int,
	@TotalBillableTime decimal (18,2) output
	)
As
  Set NoCount On;
  
  SELECT @TotalBillableTime = ROUND(SUM(SupportTicketResponseBillableTime),2) FROM SupportTicketResponses WHERE SupportTicketID = @SupportTicketID;

Any help would be greatly appreciated, thank you in advance... Oh BTW... I'm using SQL 2008 with .NET 3.5

Re: SQL SUM Decimals 80 80

Marked as solved why? If you have solution why didn't you posted?

Re: SQL SUM Decimals 80 80

Marked as solved why? If you have solution why didn't you posted?

Typically I do put the solved code for show for others that may have the same problem... It's just that I was trying out daniweb for the first time and wasn't getting a response within a reasonable amount of time, so I went back to the old tried and true forums of asp.net where I got a response right away... I didn't think it would be fair to the person that gave me the answer to share it on a different forum...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.