I have a report with date fields. I need to convert dates stored in data server in the time zone of user's machine where the report is run. The dates in data server are in GMT time zone. I am seeing report in India and expecting the date to be shown in IST time zone (i.e. GMT + 5:30).
This is very typical requirement and I have found many references to achieve this. As per one of the references [http://stackoverflow.com/questions/2969689/working-with-time-zones-in-ssrs], I have added following code in report page -
Shared Function FromUTC(ByVal d As Date, ByVal tz As String) As Date
Return (TimeZoneInfo.ConvertTimeBySystemTimeZoneId(d, TimeZoneInfo.Utc.id, tz))
And following expression in date field -
BUT I am not getting the expected result. The date is shown in report in EST time zone.
Date stored in server = 12/7/2012 02:04 PM
After adding above code & expression, I get value in report as 12/7/2012 9:04 AM , Which is EST = GMT – 5:00
And expected value is 12/7/2012 07:34 PM
How can I achieve this?
Reporting Service doesn’t provide a function that can get the TimeZone of a Client machine. Hence, we have to create a parameter through which the client users can select his/her TimeZone, and then pass the parameter value to the custom function FromUTC in the expressions.
In your scenario, the expression “=Code.FromUTC(Fields!UTCDateFromDatabase.Value,TimeZone.CurrentTimeZone.StandardName)” cannot achieve your goal. This is predictable because TimeZone.CurrentTimeZone.StandardName gets the TimeZone of Report Server side.
To achieve the goal, please refer to the steps as shown below:
1.Create a parameter named TimeZone, select Available value and click Specify values.
China Standard Time China Standard Time
2. Call the custom code and type the expression to convert the TimeZone as follows:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place.