Tuesday, December 4, 2012

SharePoint CAML query filter using date time parameter

Hi All,


I went through a scenario where I want to write and CAML query that will filter some data based on the date time value.

The issue is that CAML need to have this date time value in a specific format.

To provide the correct date time format that is recognised by CAML markup you should use SPUtility.CreateISO8601DateTimeFromSystemDateTime function on a date value that you are comparing.

Here is an example of testing that the "Expires" column is greater or equal to the current date:  

SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now)

Thanks,
Sachin K.


No comments:

Post a Comment