I'm trying to get the elements with the most new created date using CAML query in sharepoint 2007.

I can do it using:

"<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy><RowLimit>1</RowLimit>"

To get the most recent date and then use other CAML query to get the elements with that date.

But, theres no other way to do it in one consult?

  • What's your issue? You just add a ViewFields node to get the fields you want.
    – James Love
    Commented Feb 18, 2011 at 16:41

1 Answer 1


As far as I can tell, you're trying to do the SQL equivalent of a self join: Querying the maximum date in a subquery and joining back to the table on that date.

Unfortunately CAML doesn't allow you to do self joins; I'm afraid there is no way to do this in a single query.

  • 1
    Related - You can use SPList.LastModified to get the last time an item was created or modified - but no way to tell if this date was from a creation or update without further checking. msdn.microsoft.com/en-us/library/…
    – Ryan
    Commented Jul 21, 2011 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.