0

I need a CAML query to compare the Lookup Value and not ID. My Lookup Value is of DateTime. The startTime and endTime are both DateTime.

Something is wrong with the code below. I searched through the web but all I can find are Type=DateTime and not Lookup.

           "<Where>" +
                "<And>" +
                    "<Lt>" + 
                        "<FieldRef Name='" + EventSessionStartTime + "' />" +
                        "<Value Type='Lookup' IncludeTimeValue='TRUE'>" + endDate + "</Value>" +
                    "</Lt>" +
                    "<Gt>" +
                        "<FieldRef Name='" + EventSessionEndTime + "' />" +
                        "<Value Type='Lookup' IncludeTimeValue='TRUE'>" + startDate + "</Value>" +
                    "</Gt>" +
                "</And>" +
            "</Where>";
Joe
  • 151
  • 9

1 Answers1

1

Found out the answer. It is perfectly fine to compare using the above query. It will retrieve the date and time in your list.

  1. Make sure that your Internal column name is not too long as sharepoint has its limit.
  2. Make sure that your dates are standardize. You may not use the time format given be C#. I use SPUtility.CreateISO8601DateTimeFromSystemDateTime((DateTime)date) to standardize it.
Joe
  • 151
  • 9