3

我想使用以下 MDX 语句:

with member [x] as now()->plusMonths(1)->withDayOfMonth(1)->minusDay(1)
select [x] on 0
from sales

但我得到错误“withDayOfMonth”是未知的。我知道函数“plustMonths()”工作正常。如何使其他 Joda 功能正常工作?

以下行在 icCube.xml 中处于活动状态。帮助明确指出如果需要添加子包,但我不知道 withDayOfMonth 是否是子包,我不知道在哪里可以找到:

<allowedPackage>org.joda.time</allowedPackage>
4

1 回答 1

2

不幸的是,now() 正在创建一个不支持所有 JODA 方法的内部日期/时间对象(我们将在下一个版本中添加它们)。同时,这里有几种计算月末的方法:

with
 // Be aware it is the server's end of month not the client, if you don't see the problem you've been lucky...for the time being.

 // using MDX functions ( function can be added to the schema )
 function ic3_EOM() as DateTime( now().year() , now().month() +1, 1 )->plusDays(-1)

 // using JODA DateTime ( function can be added to the schema )
 function ic3_EOM_2() as J!org.joda.time.DateTime()->plusMonths(1)->withDayOfMonth(1)->minusDays(1)->toLocalDate()

 member [ic3_EOM] as ic3_EOM()
 member [ic3_EOM_2] as ic3_EOM_2()

select { [ic3_EOM], [ic3_EOM_2] } on 0 from [sales] 
于 2015-05-15T15:10:39.667 回答