Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

CAML Query question

  Asked By: Alyson    Date: Jun 16    Category: Sharepoint    Views: 2670

I am using webservices to display the data of the Sharepoint list on
a webpage outside of Sharepoint. I am passing in a CAML query with a
date param to filter out data. The query doesn't work if the date is
passed in to the query, but it works when put it as <Today />.
Please see the following CAML query:

Working query:
query.InnerXml = "<OrderBy><FieldRef Name=\"+EventDate\"+
"<Gt><FieldRef Name=\"EventDate\" />"+
"<Value Type=\"DateTime\"><Today /></Value></Gt></Where>";

Not working:
query.InnerXml = "<OrderBy><FieldRef Name=\"+EventDate\"+
"<Gt><FieldRef Name=\"EventDate\" />"+
"<Value Type=\"DateTime\">+DateTime.Today+</Value>"+

Can someone shed some light what am I doing working?



4 Answers Found

Answer #1    Answered By: Jennifer Jones     Answered On: Jun 16

Sharepoint works  with dates in the ISO8601 format: yyyy-mm-ddThh:mm:ssZ. This page has all the information. blog.u2u.info/.../3010.aspx

Long story short, you need this SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today)

Answer #2    Answered By: Annie Norris     Answered On: Jun 16

When I tried using SPUtility.CreateISO8601DateTimeFromSystemDateTime
(DateTime.Today), I get this "System.Security.SecurityException:
Failure decoding embedded permission set object."

Any suggestions why am I getting this error?

Answer #3    Answered By: Chadd Hahn     Answered On: Jun 16

the normal datetime  object also has a method that returns the date  in the required format you can use that itself. It works  fine for me.

Answer #4    Answered By: Cheryl Kelley     Answered On: Jun 16

It's likely the formatting of the date. CAML is particular aboutlots of stuff
including date  formats.

Didn't find what you were looking for? Find more on CAML Query question Or get search suggestion and latest updates.