如何使用MDX查询获取当前年份?

时间:2012-11-14 01:50:50

标签: mdx

我对MDX一点兴趣。 有没有办法通过MDX查询从系统/服务器获取当前年份? 我没有任何与日期相关的维度或类似的东西。

问候。

1 个答案:

答案 0 :(得分:1)

创建一个成员并将其定义为'YEAR(NOW())'

Member [Measures].[Current Year] as 'YEAR(NOW())'

这是更多complete sample

-- The First Calculated member is the value of NOW()
WITH  MEMBER [Measures].[Full Date] as 'NOW()'
-- The Second Calculated Member is the Day part of the first calculated member.
MEMBER [Measures].[What Day] as 'DAY([Full Date])'
-- The Third Calculated Member is the Month part of the first calculated member.
MEMBER [Measures].[What Month] as 'MONTH([Full Date])'
-- The Fourth Calculated Member is the Year part of the first calculated member.
Member [Measures].[What Year] as 'YEAR([Full Date])'
SELECT
   {[Full Date],[What Day],[What Month],[What Year]} ON COLUMNS
FROM [Your Cube]