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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Convert UTC datetime to localtime

Thread ID:

Created:

Updated:

Platform:

Replies:

145025 May 31,2019 09:14 AM UTC Jun 4,2019 01:26 PM UTC Dashboard Platform 5
loading
Tags: Dashboard Designer
Malcolm van Staden
Asked On May 31, 2019 09:14 AM UTC

Hi,

We have a dataset that contains UTC dates which we'd like to display as local dates (server local time). Is there a way to do this with the report designer using an expression column?

-Malcolm 

Vinoth Srinivasan [Syncfusion]
Replied On May 31, 2019 06:27 PM UTC

Hi Malcolm, 

You can use the below expression in our report designer to convert the UTC datetime to local date time. 

=System.TimeZone.CurrentTimeZone.ToLocalTime(Parameters!DateParameter.Value) 
 

We have prepared a simple sample report based on this and it can be downloaded from the below location. 


Regards, 
Vinoth S. 


Malcolm van Staden
Replied On June 1, 2019 08:01 AM UTC

Hi,

Thank you for that information. I see I said report designer, but what I meant to say was dashboard designer. I'll see if I can log this under the correct category.

-Malcolm

Renuka N [Syncfusion]
Replied On June 3, 2019 07:27 AM UTC

Hi Malcolm, 
 
Thanks for your update.
 
Using Expression column, we can’t able to convert UTC time to local time in Dashboard Designer. You can achieve your requirement using code view option if you are using server types connection like SQL, MySQL and Postgres. 
 
For SQL server you can use DATEADD() function to add the hours or minutes in your date.  
Example:  If your local time is 2h ahead of Universal Coordinated Time, then you can add below line in your code view to achieve your requirement, 
DATEADD(hour, 2, [date time column]) as [LocalTime] 
 
If your local time is 5h 30m ahead of Universal Coordinated Time, then you can add below line in your code view to get the local time, 
DATEADD(mi, 330, [date time column]) as [LocalTime] 
Note: Here we have converted the 5 h 30 m to minutes (330) and then add the value with your date time column.  
 
Please refer below screen shot for your reference, 
  
 
For MySQL server, you can use DateAdd() function like as below,’ 
DATE_ADD([date column], INTERVAL 2 HOUR) as “LocalTime” 
 
For Postgres server, you can use DateADD() function like as below, 
[date column] + INTERVAL ‘2 hour’ as “LocalTime” 
 
Kindly refer below documentation link to know more about code view support in Dashboard Designer, https://help.syncfusion.com/dashboard-platform/dashboard-designer/connecting-to-data/connecting-through-custom-sql-query 
 
Please let us know if you need any further assistance.
 
Regards,
Renuka N.


Malcolm van Staden
Replied On June 4, 2019 07:24 AM UTC

Hi Renuka,

Thank you for that information. Unfortunately we are using an API which provides JSON data. We are unable to change the data at the source and would much rather prefer to make use of the DATEADD function within the dashboard designer to display the field correctly. 

I will log a feature request to see if it's something that can be implemented.

Regards,
-Malcolm

Dhivyabharathi Govindaraj [Syncfusion]
Replied On June 4, 2019 01:26 PM UTC

Hi Malcolm, 
 
We can achieve this requirement by using Code view in Dashboard Web Designer. 
 
Please follow the below steps to convert UTC to local time under Code view as shown below. 
 
DATEADD() function can be used to add the hours or minutes in date.  
 
Example:  If your local time is 2h ahead of Universal Coordinated Time, then you can add below line in your code view to achieve your requirement,  
DATEADD(hour, 2, [date time column]) as [LocalTime]  
  
If your local time is 5h 30m ahead of Universal Coordinated Time, then you can add below line in your code view to get the local time,  
DATEADD(mi, 330, [date time column]) as [LocalTime]  
Note: Here we have converted the 5 h 30 m to minutes (330) and then add the value with your date time column.   
  
Please refer below screen shot for reference, 
 
To connect On-premises Web Designer product kindly follow below steps, 
  1. Go to Dashboard Server and Click Add button. Choose Create-> Dashboard option,
 
 
  1. To connect Web API, enable Data Store Settings option of Dashboard Server,
 
  1. Choose Web API connection from Database list like as below and chose code view option to achieve your requirement.
 
 
 
Kindly refer below documentation link to know more about our Web Designer product, https://help.syncfusion.com/dashboard-cloud/dashboard-designer-walk-through . 
 
Currently we don’t have support to achieve your requirement using Expression function but we have logged a feature request on this and it can be tracked through our feedback portal below, https://www.syncfusion.com/feedback/5405/add-more-functions-for-expression-editor-in-syncfusion-dashboard-cloud 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Dhivya 
 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon