CRM 2011 Online SSRS report UTC time to local time

来源:互联网 发布:网络密钥怎么设置 编辑:程序博客网 时间:2024/05/19 04:03

在CRM数据库中存储的时间都是UTC时间,所以当我们在做报表的时候需要将UTC时间转换为本地时间。

对于CRM On-premise来说,我们可以使用Filtered View,比如Filteredaccount里就有createdon和createdonUTC两列,createdon里的值就是本地时间了。

但对于 CRM Online来说,我们需要使用Fetch XML来query数据,就无法使用FilteredView了。我们从数据库中query来的只有UTC时间,我们需要在报表中将它转换为本地时间。如果你利用ReportWizard来生成一个最简单的报表,并包含一个createdon列在报表的table中,我们就可以看到这个转换函数了:

Microsoft.Crm.Reporting.RdlHelper.DateTimeUtility.ConvertUtcToLocalTime(Fields!createdonValue.Value,Parameters!CRM_UserTimeZoneName.Value)

下面我把整个xml拷贝下来:

 

<Textbox Name="Table0_Header1">  <CanGrow>true</CanGrow>  <UserSort>    <SortExpression>=Microsoft.Crm.Reporting.RdlHelper.DateTimeUtility.ConvertUtcToLocalTime(Fields!createdonValue.Value, Parameters!CRM_UserTimeZoneName.Value)</SortExpression>  </UserSort>  <KeepTogether>true</KeepTogether>  <Paragraphs>    <Paragraph>      <TextRuns>        <TextRun>          <Value>="Gemaakt op"</Value>          <Style>            <FontFamily>Tahoma</FontFamily>            <FontSize>8pt</FontSize>            <FontWeight>Bold</FontWeight>            <Color>#ffffff</Color>            <Language>nl-NL</Language>          </Style>        </TextRun>      </TextRuns>      <Style>        <TextAlign>Center</TextAlign>      </Style>    </Paragraph>  </Paragraphs>  <Style>    <BackgroundColor>#4f81bd</BackgroundColor>    <PaddingLeft>2pt</PaddingLeft>    <PaddingRight>2pt</PaddingRight>    <PaddingTop>2pt</PaddingTop>    <PaddingBottom>2pt</PaddingBottom>  </Style></Textbox>


原创粉丝点击