Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 与MDX语言无关的日期比较_Date_Mdx - Fatal编程技术网

Date 与MDX语言无关的日期比较

Date 与MDX语言无关的日期比较,date,mdx,Date,Mdx,简言之:我有一个日期类型属性,需要与now()进行比较,但有两个不同的环境(语言设置)需要进行比较 我有以下代码的密码: with member [Measures].[Opening] as CDate([Store].[Store].Properties('Opening')) // works with the english date member [Measures].[Opening] as // works with the german date

简言之:我有一个日期类型属性,需要与now()进行比较,但有两个不同的环境(语言设置)需要进行比较

我有以下代码的密码:

with
    member [Measures].[Opening] as
        CDate([Store].[Store].Properties('Opening')) // works with the english date

    member [Measures].[Opening] as // works with the german date
        DateSerial(
            Right([Store].[Store].Properties('Opening'),4),
            Mid([Store].[Store].Properties('Opening'),4,2),
            Left([Store].[Store].Properties('Opening'),2)
        )

    member [Measures].[IsOpen] as
        CASE 
            WHEN [Measures].[Opening] < NOW()
                THEN 1 
                ELSE 0 
        END
与
成员[措施][开始]为
CDate([Store].[Store].Properties('Opening')//用于英文日期
成员[测量][开始]作为//使用德国日期
日期序列(
右([Store][Store].Properties('Opening'),4),
Mid([Store][Store].Properties('Opening'),4,2),
左([Store][Store].Properties('Opening'),2)
)
成员[措施][IsOpen]为
案例
当[测量][打开]
[Store][Store].Properties('Opening')
是一个日期

但有两台服务器具有不同的语言设置,必须在其上运行。一个返回,例如2009年10月2日,另一个返回2009年2月10日,用于[开幕]

我需要找到一个同时适用于这两种环境的解决方案。(但无法更改语言设置)


我尝试用格式字符串或语言格式化,但没有成功。

一个可能的想法是:

  VBA!cdate(
    format(
      VBA!cdate([Store].[Store].Properties('Opening')),
      "dd MMMM yyyy"
    )
  )
很多仓库都使用整数作为日期键-那么服务器的日期格式将稍微不相关,因为您可以使用这种结构:

MEMBER [Measures].[Date as int] as
       [Date].[Date].CURRENTMEMBER.Properties('Key0', Typed)
MEMBER [Measures].[Date Year] as
       Fix([Measures].[Date as int] / 10000)
MEMBER [Measures].[Date Month] as
       Fix(([Measures].[Date as int] - [Measures].[Date Year] * 10000) / 100)
MEMBER [Measures].[Date Day] as
       [Measures].[Date as int] - [Measures].[Date Year] * 10000 - [Measures].[Date Month] * 100

MEMBER [Measures].[DateValue_attempt1] as
       // convert it to Date data type and use a format string on that:
       DateSerial([Measures].[Date Year], [Measures].[Date Month], [Measures].[Date Day]),
       format_string = 'dd.MM.yyyy'
MEMBER [Measures].[DateValue_attempt2] as
       //if above fails maybe just convert it to string & do further conversion in client
       [Measures].[Date Day] + "." +
          [Measures].[Date Month] + "." +
             [Measures].[Date Year]
但一个解决方法可能是检测第三个字符是什么,然后使用
IIF
CASE

WITH
    MEMBER [Measures].[Opening] AS
       IIF(
          Mid([Store].[Store].Properties('Opening'),3,1) = '.'
         ,DateSerial(
            Right([Store].[Store].Properties('Opening'),4),
            Mid([Store].[Store].Properties('Opening'),4,2),
            Left([Store].[Store].Properties('Opening'),2)
          )
         ,CDate([Store].[Store].Properties('Opening')) 
       )

我的哪一段有用?第三段有用。