如何实现近期记录筛选
【问题】
I have defined a domain that joins a few tables, and I’d like to limit the result set by applying a pre-filter that will only return recent (last 30 days) of records. I am using SQL server, so the SQL syntax would be:
where MyTable.DateTimeField > getdate() - 30
If I add a pre-filter using an absolute date, I see the following in the exported domain XML:
MyTable.DateTimeField > ts’2014-11-11’
And this works fine. How can I change the absolute day to TODAY - 30? I have tried many combinations. I have looked at the semanticlayer.xml, but nothing seems to work. Any help would be grately appreciated!
【回答】
用 SPL 可以很方便的实现 sql 的查询,并且方便的传递从今天起前 30 天(今天 -30)时间段的参数:
| A |
---|---|
1 | return myDB1.query(“select * from MyTable where DateTimeField>?”,now()-30) |
A1:查询并返回从今天起前 30 天的记录,MyTable 和 DateTiemField 可以根据自己的实际表信息填写。