hh:mm:ss MDX中的日期格式

问题描述 投票:0回答:2

如何在MDX中以时分秒(06:13:47)格式获取当前日期?

我正在尝试在所使用的多维数据集中的“计算”选项上创建一个“新计算成员”。

CALCULATE;
CREATE MEMBER CURRENTCUBE.[Measures].AverageAnalysisTimeFormatted
AS FORMAT([Measures].[AverageAnalysisTime], "HH:MM:SS"),
VISIBLE = 1 ;

我当前的内部结果(没有计算所得成员)为AnalysisTime = 1574,30

哪个是1574秒,即26分钟。

sql visual-studio mdx analysisservices
2个回答
2
投票

尝试一下,我在Adventure Works多维数据集上得到了00:26:14:

with member measures.AverageAnalysisTime as 1574

member measures.AverageAnalysisTimeFormatted as measures.AverageAnalysisTime / (3600.0 * 24.0)
           ,format_string = 'hh:mm:ss'


           select measures.AverageAnalysisTimeFormatted on 0 from [Adventure Works]

enter image description here


1
投票

您需要使用“ Now”和“ Cstr”函数。看看下面的查询

与成员措施如cstr(datepart(“ h”,Now()))+':'+ cstr(datepart(“ n”,Now()))+':'+ cstr(datepart(“ s”,Now()))]] >

select 
{
[Measures].[Internet Sales Amount],measures.t 
}
on columns,
[Product].[Category].[Category]
on rows 
from 
[Adventure Works]

结果

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.