Wow, it’s been over a week since ODC2008 and I haven’t posted, how slack of me. It’s been a busy week talking about a lot of the cool things that I saw at ODC and cutting a lot of code.
Anyway I noticed that there is almost no documentation around how to do date based queries in CAML, particularly when you want to use a date that is evaluated at runtime.
The CAML query below show how to find items that have an ImageCreateDate in the last seven days.
<Query> <Where> <Geq> <FieldRef Name="ImageCreateDate" /> <Value Type="DateTime"> <Today OffsetDays="-7" /> </Value> </Geq> </Where> </Query>
There you go, easy date math in CAML!