We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
If you became a customer of the Syncfusion Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion for your reporting needs.

Convert UTC to LocalTime

All timestamps within our database are set as UTC. If we now want to show those to the end user via report, I want them to be in Local Time. While working with SSRS we used the function "=System.TimeZone.CurrentTimeZone().ToLocalTime(Fields!UTCBegin.Value)"

Is there any equivalent we can use on the SyncFusion platform or is it possible to include the .NET functions by adding a reference to the report and if so, how?!

Thanks for your help!

3 Replies

VS Vinoth Srinivasan Syncfusion Team September 7, 2017 12:04 PM UTC

Hi Björn, 
 
Thanks for your interest in Syncfusion components. 
 
Query 
Response 
All timestamps within our database are set as UTC. If we now want to show those to the end user via report, I want them to be in Local Time. While working with SSRS we used the function "=System.TimeZone.CurrentTimeZone().ToLocalTime(Fields!UTCBegin.Value)"

Is there any equivalent we can use on the SyncFusion platform
 
You can able to convert the timestamp values to the local time zone, using the below expression. 
 
“=TimeZone.CurrentTimeZone.ToLocalTime(ReportItems!Textbox2.Value)” 
 
We have prepared a simple report based on this and it can be downloaded from the below location. 
 
is it possible to include the .NET functions by adding a reference to the report and if so, how?! 
The custom code support allows to use the .NET functions in reporting control. You can set the custom code for the report properties dialog box as described below. 
 
1. Please click on the gray area of the report designer. 
 
 
 
2 . Click the report properties and select the Code tab. 
 
 
 
3 .Now, enter the below code as custom code to convert the timestamp values. 
 
Public Function Convert(Text As DateTime) As DateTime 
return System.TimeZone.CurrentTimeZone().ToLocalTime(Text) 
End Function 
 
You can call this function from the required textbox using the following expression. 
 
=Code.Convert(Fields!UTCBegin.Value) 
 
We have prepared a simple report based on this and it can be downloaded from the below location. 
 
 
 
Regards, 
Vinoth S. 



NE Nellinger September 8, 2017 03:21 PM UTC

Thanks for your detailed reply and using the conversion now works for me!

Unfortunately I am now facing a similar problem: As all timestamps in the database are UTC based, and the user enters the preferred time range with two parameters (DT_From and DT_To), I have to convert those two timestamps from Local to UTC time. When I try to apply this in the filters section of the DataSet with the following expression

=TimeZone.CurrentTimeZone.ToUniversalTime(Parameters!DT_From.Value)

I get the an error message with sth. like this: Error while initialize the report: length may not be smaller than 0. Parameter name: length

What am I doing wrong?

Thanks!!



VS Vinoth Srinivasan Syncfusion Team September 11, 2017 08:59 AM UTC

Hi Björn, 

We were able to reproduce the reported issue. A support incident has been created under your account and we request you to login into our Direct Trac support system for further updates on this issue. Our Direct Trac support system can be accessed from the following link: 


Regards, 
Vinoth S. 


Loader.
Up arrow icon