我试图从参数化的日期检索一个月,使用VBA函数来检索日期参数的月份:无法通过使用MDX
vba!month(${parDate}) or
vba!datePart(m,${parDate}) or
vba!format(${parDate},'mmm')
以上都不是你working.Can指导,什么是正确的方法来做到这一点?
我试图从参数化的日期检索一个月,使用VBA函数来检索日期参数的月份:无法通过使用MDX
vba!month(${parDate}) or
vba!datePart(m,${parDate}) or
vba!format(${parDate},'mmm')
以上都不是你working.Can指导,什么是正确的方法来做到这一点?
(尝试大写的“MM”,而不是“嗯” - 即使是“毫米”是错误的,因为它会寻找几分钟而不是几个月)
这个问题的答案看使用日期: Changing a date format to a shorter date
MSDN是mdx
中可用的vba
函数的一个很好的参考,您可以使用它来玩弄日期。当前的链接在这里: http://msdn.microsoft.com/en-us/library/hh510163.aspx
我假设你有一个日期维度,并且想创建一个返回数字值的计算度量值,该度量值是该月份。
使用AdWks
我可以做到以下几点:
WITH
MEMBER [Measures].[DateValue] AS
[Date].[Calendar].CurrentMember.MemberValue
MEMBER [Measures].[DateKey] AS
[Date].[Calendar].CurrentMember.Member_Key
MEMBER [Measures].[DateMONTH] AS
Mid
(
[Measures].[DateKey]
,5
,2
)
SELECT
{
[Measures].[DateValue]
,[Measures].[DateKey]
,[Measures].[DateMONTH]
} ON 0
,Order
(
{
Exists
(
[Date].[Date].MEMBERS
,[Date].[Calendar Year].&[2010]
)
}
,[Date].[Calendar].CurrentMember.MemberValue
,BDESC
) ON 1
FROM [Adventure Works];
但是,也许你只是想玩弄今天的日期,并提取了一个月:
WITH
MEMBER [Measures].[DateValue] AS
[Date].[Calendar].CurrentMember.MemberValue
MEMBER [Measures].[TodayKey] AS
format(Now(),'yyyMMdd')
MEMBER [Measures].[TodayMONTH] AS
Mid
(
[Measures].[TodayKey]
,5
,2
)
SELECT
{
[Measures].[DateValue]
,[Measures].[TodayKey]
,[Measures].[TodayMONTH]
} ON 0
,Order
(
{
Exists
(
[Date].[Date].MEMBERS
,[Date].[Calendar Year].&[2010]
)
}
,[Date].[Calendar].CurrentMember.MemberValue
,BDESC
) ON 1
FROM [Adventure Works];
任何一个可以告诉我做什么我错了? – sam140 2014-11-21 18:31:22
你在哪个环境工作?什么语言?这看起来不像MDX语句,不像SQL语句,就像来自任何代码片段一样。你能举出一个可能包含在变量'parDate'中的示例吗? – FrankPl 2014-11-21 19:10:43
我认为与这个问题有关,这是一个完整的答案:http://msdn.microsoft.com/en-us/library/hh510163.aspx什么是您的片段的上下文? – whytheq 2014-11-22 02:19:55