none
Convert UTC time to local time

    Question

  • Hello,

    I am new with the reporting services. I am creating a report and I need to display date/time on the report. But the servers stores those date/time in UTC. How can I convert them to the local time in my report.

     

    Thanks for your help.

     

     

    Thursday, December 29, 2005 3:40 PM

Answers

  • Try this instead:
    =System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!DateTime.Value)

    -- Robert

    Tuesday, May 30, 2006 3:51 PM
    Owner
  • You need to use System.TimeZone.ToLocalTime(UTCTime).

    See http://msdn2.microsoft.com/en-us/library/system.timezone.tolocaltime.aspx.

    You should be able to use TimeZone.CurrentTimeZone if you want to convert using the server time zone.

    Thursday, December 29, 2005 8:09 PM
  • Report expressions are executed on the server, therefore it is the timezone of the server.

     

    I think the closest you can get is to add for instance a hidden parameter populated/set with a specific timezone value.  The report would then need to take into account the parameter's value to perform timezone conversions.

     

     

    -- Robert

    Monday, October 08, 2007 12:18 AM
    Owner

All replies

  • You need to use System.TimeZone.ToLocalTime(UTCTime).

    See http://msdn2.microsoft.com/en-us/library/system.timezone.tolocaltime.aspx.

    You should be able to use TimeZone.CurrentTimeZone if you want to convert using the server time zone.

    Thursday, December 29, 2005 8:09 PM
  • Hello,

    i tried this tip with no luck.

    I used the expression = System.TimeZone.ToLocalTime(!Fields.DateTime.Value) in one of my cells and got an BC30469 error.

    Tuesday, May 30, 2006 11:45 AM
  • Try this instead:
    =System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!DateTime.Value)

    -- Robert

    Tuesday, May 30, 2006 3:51 PM
    Owner
  • Robert,

    thanks alot. Works like a charm.

    Wednesday, May 31, 2006 7:16 AM
  • This works for conversion based on the time zone of the report server, but not the client.  Is that correct?  I tested this by using the function in a textbox on the report that I deployed to the report server.  Then on my workstation PC, I changed my timezone and viewed the report.  The time in the report still reflected the time on the report server (converted from the UTC time of course).

    How do you change the dates in the reports dynamically based on the area of the country someone opens the report?  Because the report renders as HTML first before being delivered to the client, does this mean it will always use the report server time zone?

    Thanks

    -Kory

    Thursday, January 18, 2007 4:43 PM
  • I have the same question as KoryS.  Anyone have an answer?

    Thanks.
    Friday, October 05, 2007 6:21 PM
  • Report expressions are executed on the server, therefore it is the timezone of the server.

     

    I think the closest you can get is to add for instance a hidden parameter populated/set with a specific timezone value.  The report would then need to take into account the parameter's value to perform timezone conversions.

     

     

    -- Robert

    Monday, October 08, 2007 12:18 AM
    Owner
  •  SMaste wrote:

    Hello,

    I am new with the reporting services. I am creating a report and I need to display date/time on the report. But the servers stores those date/time in UTC. How can I convert them to the local time in my report.

     

    Thanks for your help.

     

     

    Thursday, April 10, 2008 4:11 PM
  • How we can do when we have several client around the world ?

    The temporary solution that I have put in place is that I have added a Visible parameter with all the Time zone (13),

    This solution is not dynamic as the user should select its time zone before rendering the report.

    A solution that detect and select automatically the client time Zone will be more efficient

    Anybody has a better solution ?

     

    Thursday, January 29, 2009 10:18 PM
  • Hi Denfer,

    Could you please post the temporary solution that you have?

    Thanks!

    Regards,

    Anusha.

    Friday, July 09, 2010 11:24 AM