none
SSRS code added to work with time zones does not give client/user machine time

    Question

  • Hi,

    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))

    End function

    And following expression in date field -

    =Code.FromUTC(Fields!UTCDateFromDatabase.Value, TimeZone.CurrentTimeZone.StandardName)

    BUT I am not getting the expected result. The date is shown in report in EST time zone.

    Example,

    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?

    Tuesday, October 15, 2013 6:48 AM

Answers