【问题标题】:Datetime comparison in CAML Query for SharepointSharepoint 的 CAML 查询中的日期时间比较
【发布时间】:2011-06-06 14:50:45
【问题描述】:

我正在尝试从共享点列表中获取一些项目,这取决于自定义列中的日期。

我已经使用 U2U Caml Builder 创建了我的查询,这很有效,但是当我将它放入我自己的 webpart 代码中时,它总是返回给我列表中的所有项目。

这是我的代码:

DateTime startDate = new DateTime(Int32.Parse(year), 1, 1);
            DateTime endDate = new DateTime(Int32.Parse(year), 12, 31);
            SPQuery q = new SPQuery();
            q.Query = "<Query><Where><And><Geq><FieldRef Name='Publicate Date' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(startDate) + "</Value></Geq><Leq><FieldRef Name='Publicate_x0020_Date' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(endDate) + "</Value></Leq></And></Where></Query>";

            SPListItemCollection allItem = library.GetItems(q);

【问题讨论】:

    标签: c# sharepoint web-parts caml


    【解决方案1】:

    您不需要&lt;Query&gt; 标签。这就是为什么您的查询没有被执行。

    【讨论】:

    • 非常感谢!!!最糟糕的是,我已经在这个该死的错误上帮助了一位同事哈哈哈!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多