如何按日期范围值过滤执行查询? [英] How to filter in execute query by Date range value?

查看:95
本文介绍了如何按日期范围值过滤执行查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在executeQuery中进行 Query ,并且必须按日期字段进行过滤, 我的代码是:

I have to made a Query in executeQuery , and I have to filter by date field, my code is :

public void executeQuery()
{
    utcDateTime dateUTC, datenullUTC;
    query q = new Query();

    QueryBuildRange qbr;
    QueryBuildDataSource qbds ;
    QueryRun queryRun;

    dateUTC = DateTimeUtil::newDateTime(_dateValue, 0, DateTimeUtil::getCompanyTimeZone());

    qbds = q.addDataSource(tableNum(MCRCustCategory) ); 

    qbds.addRange(fieldNum(MCRCustCategory, ValidTo)).value(strFmt ("> %1", dateUTC) );

    queryRun = new QueryRun (q);

    super();
}

在我的init中,我调用了 executeQuery ,但没有在表单中进行过滤.

In my init I call the executeQuery, but don't filter in my Form.

如何使用范围中的日期?

How to use the date in the Range ?

谢谢,

享受!

推荐答案

您使用的表使用

You use a table which use date effective. You assume you have to do the selection yourself, this is not true.

改为使用此:

public void executeQuery()
{
    this.queryBuildDataSource().validTimeStateAsOfDate(_dateValue);
    super();
}

如果有间隔,请改用此间隔:

If you have an interval, use this instead:

this.queryBuildDataSource().validTimeStateDateRange(fromDate, toDate)

问题中提供的代码根本不做任何事情,因为表单不使用您构建的查询.反正您建立了错误的查询!

Your code as provided in the question does not do anything at all, as the form does not use the query you build. You buildt the wrong query anyway!

博客帖子对此进行了简要说明.

This blog post explains it concisely.

这篇关于如何按日期范围值过滤执行查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆