CAML and Date Formats

Patrick beat me to the punch and posted about date formatting with CAML (it was sitting in my blog TODO pile, I *knew* I should have blogged last night). The date format works alone and will return values. I just wanted to add to his post that you can add a time to the date as well if you want to a query for a particular time. For dates with time the format of the query has to be: 

<Query>

<Where>

<Leq>

<FieldRef Name="EventDate" />

<Value Type="DateTime">2005-05-27T16:00:00Z</Value>

</Leq>

</Where>

</Query>

 

So this would return all items in a list that has a field called EventDate with a value before 4:00PM on Friday, May 27, 2005.

Published Friday, May 27, 2005 3:02 AM by Bil Simser
Filed under:

Comments

# re: CAML and Date Formats

Saturday, May 28, 2005 11:41 AM by Mike Walsh Helsinki
Grabbed and placed here

http://www.asaris-matrix.com/mvp-walsh/Lists/WSS%20FAQ/DispForm.aspx?ID=470

I'll remove it (or at least your bit) if you scream!

Mike

# re: CAML and Date Formats

Sunday, May 29, 2005 2:39 AM by MikeWalshHelsinki
Make that ID=471 - I moved it. Mike