如何实现近期记录筛选

【问题】

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
1return myDB1.query(“select * from MyTable where DateTimeField>?”,now()-30)

A1:查询并返回从今天起前 30 天的记录,MyTable 和 DateTiemField 可以根据自己的实际表信息填写。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值