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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Convert UTC to LocalTime

Thread ID:

Created:

Updated:

Platform:

Replies:

132524 Sep 6,2017 03:50 PM UTC Sep 11,2017 08:59 AM UTC Report Platform 3
loading
Tags: Report Designer
Nellinger
Asked On September 6, 2017 03:50 PM UTC

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!

Vinoth Srinivasan [Syncfusion]
Replied On 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. 


Nellinger
Replied On 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!!


Vinoth Srinivasan [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;