S
sucharith
I have a datatable with some columns of int data type. I have been
using the datatable.compute() method to calculate the average of a
particular columns for all rows. But the result given is of type int
and not float. In essence it is reportingthe avg of 2 and 3 as 2 and
not 2.5.
If I convert the type definition of the column to double it works
fine.
Is there any method to make it return double type values without
changing teh data types. I have tried using Convert() but it Think I
am messing up somewhere.
Dim dt As New Dataset1.TestDataDataTable
Dim dr As Dataset1.TestDataRow
Dim x
For x = 1 To 10
dr = dt.NewTestDataRow
dr.Name = " Name" & x
dr.Age = x
dt.AddTestDataRow(dr)
Next
Debug.WriteLine("Average Age=" & dt.Compute("AVG(Age)", ""))
Age is defined as int. Teh correct avg for this code is 5.5 but it
reports 5.
Thank in advance.
Sucharith
using the datatable.compute() method to calculate the average of a
particular columns for all rows. But the result given is of type int
and not float. In essence it is reportingthe avg of 2 and 3 as 2 and
not 2.5.
If I convert the type definition of the column to double it works
fine.
Is there any method to make it return double type values without
changing teh data types. I have tried using Convert() but it Think I
am messing up somewhere.
Dim dt As New Dataset1.TestDataDataTable
Dim dr As Dataset1.TestDataRow
Dim x
For x = 1 To 10
dr = dt.NewTestDataRow
dr.Name = " Name" & x
dr.Age = x
dt.AddTestDataRow(dr)
Next
Debug.WriteLine("Average Age=" & dt.Compute("AVG(Age)", ""))
Age is defined as int. Teh correct avg for this code is 5.5 but it
reports 5.
Thank in advance.
Sucharith