简体   繁体   中英

CAML Query get elements with most recent created date

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?

If you're looking for a specific date (eg : all the news that were created five years ago, but you don't know the magic number five) I would do the same, you can always limit the viewfields in your query to limit the fields that are retrieved (already well stripped with rowlimit=1).

There might be a way with groupby to get something similar or you can get the last x items order by date (if you know that for example, no more than x items are created per specific date) and do some post processing in Linq, but at first sight, you're on the good track.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM