Ishan
Ishan

Reputation: 4028

CAML query with date filter, working in U2U query builder but not working in C# code

Here is a CAML query which works fine in query builder but does not work work when used in code.

lstEmpQuery.Query = string.Concat("<Where><And><And><IsNotNull>" +
                                  "<FieldRef Name='Domain_x0020_Name' />" +
                                  "</IsNotNull><Leq>" +
                                  "<FieldRef Name='Start_x0020_Date' /><Value Type='DateTime'>[Today+0Day(s)]</Value>" +
                                  "</Leq></And><Eq><FieldRef Name='Is_x0020_Leaver_x003f_' /><Value Type='Boolean'>0</Value>" +
                                  "</Eq></And></Where>");

The query works fine in code and in query builder when date filter is removed i.e without the below piece

[Today+0Day(s)]

How can i make the query work withe the date filter. I tried passing DateTime.Now instead of [Today+0Day(s)] but still it does not work.

Kindly help in this issue. Thank You.

Upvotes: 0

Views: 1473

Answers (1)

Ishan
Ishan

Reputation: 4028

Replaced with <Today/> instead of [Today+0Day(s)] and its working.

Upvotes: 2

Related Questions