CRM 2011 Online SSRS report UTC time to local time

在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>

欢迎大家关注我的公众号,阅读更多文章,获取更多知识

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值