Skip to main content
edited
Source Link
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61
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);
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);
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);
added 1520 characters in body
Source Link
Submits
  • 3.3k
  • 3
  • 23
  • 37

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);

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);
Source Link
Submits
  • 3.3k
  • 3
  • 23
  • 37

"float;#22.0000000000000" Number Returned From CAML Query

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?