views:

32

answers:

1

Can u tell me how to compare the date as well as time stored in a SPList as a DateTime field with the current system time using a CAML query?

+5  A: 

To compare with todays date:

<Where>
  <Lt>
    <FieldRef Name='Created'/>
    <Value type='DateTime'><Today /></Value>
  </Lt>
</Where>

To compare todays date AND time

<Where>
  <Lt>
    <FieldRef Name='Created'/>
    <Value type='DateTime' IncludeDateTime='TRUE'><Today /></Value>
  </Lt>
</Where>

To compare yesterdays date

<Where>
  <Lt>
    <FieldRef Name='Created'/>
    <Value type='DateTime'><Today Offset='-1' /></Value>
  </Lt>
</Where>
Janis Veinbergs