如何按日期范围值过滤执行查询?

编程入门 行业动态 更新时间:2024-10-26 00:24:15
本文介绍了如何按日期范围值过滤执行查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我必须在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.

更多推荐

如何按日期范围值过滤执行查询?

本文发布于:2023-10-28 23:13:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538044.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按日

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!