I'm running a CAML query to retrieve list items. Some of the columns retrieved contain decimal numbers. The problem is the values coming back from the query look like float;#22.0000000000000
. I just need 22.0
.
I've tried using ToString()
, Decimal.Parse
, casting with (float)
, (double)
, etc. and they all give me exceptions.
How can I resolve this? Why is this even happening?
CAML query (Approved, Pending and Remaining contain decimal numbers):
SPQuery qry = new SPQuery();
qry.Query = String.Format(
@" <Where>
<And>
<Eq>
<FieldRef Name='Person' />
<Value Type='Integer'>
<UserID />
</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name='Year' />
<Value Type='Choice'>{0}</Value>
</Eq>
<Eq>
<FieldRef Name='Year' />
<Value Type='Choice'>{1}</Value>
</Eq>
</Or>
</And>
</Where>", currentYear.ToString(), (currentYear + 1).ToString());
qry.ViewFields = @"<FieldRef Name='Approved' /><FieldRef Name='Pending' /><FieldRef Name='Remaining' /><FieldRef Name='Year' />";
SPListItemCollection items = leaveEntList.GetItems(qry);