Saturday, 10 November 2012

Dynamics CRM 2011 – Date Time field in custom SSRS report

While using any Date field in your Report you have to be careful about the user’s time zone. Dynamics CRM 2011 stores the date in UTC format so the developer needs to convert it to the preferred date format of user.

Solution

In Report Properties Reference Section add a reference to Microsoft.Crm.Reporting.RdlHelper assembly. Also add a parameter CRM_UserTimeZoneName and set its default value to GMT Standard Time. Whenever you use the date field on report convert the UTC format of date to the user timezone. Use the expression given below:

=CStr(Format(IIf(IsNothing(Fields!ink_billingperiodfromutc.Value),
                            Nothing,                            CDate(Microsoft.Crm.Reporting.RdlHelper.DateTimeUtility.ConvertUtcToLocalTime
                                  (Fields!ink_billingperiodfromutc.Value,                                    Parameters!CRM_UserTimeZoneName.Value))),"dd MMM yyyy"))

I hope this will be helpful.

No comments:

Post a comment