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
close icon

Convert UTC datetime to localtime

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 dashboard designer using an expression column?

-Malcolm

1 Reply

RN Renuka N Syncfusion Team June 3, 2019 07:25 AM UTC

Hi Malcolm, 
 
Thanks for contacting Synfusion support.
 
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.


Loader.
Live Chat Icon For mobile
Up arrow icon