Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

I'm connecting to an MS SQL database via Power Query (Version: 2.10.3598.81) in Excel 2010.

My dates are stored in UTC in the database, however I would like to show them as local in the spreadsheet.

DateTimeZone.From() - converts to a DateTimeZone type but assumes the input date is in the Local timezone. This is the exact opposite of what I want.

DateTimeZone.ToLocal() - gives an error, I think because there's no timezone information in the source date.

Local in my case is Australian EST, however, it would be great if Excel just picked up the local timezone. (It appears to do this already)

closed

1 Answer

0 votes
by (47.2k points)
selected by
 
Best answer

The DateTime.AddZone() function is used to convert between time zones, and can be leveraged to add timezone information to an existing date. If your date is UTC you would use DateTime.AddZone([date_created],0) and if your date was already in AEST then you would use DateTime.AddZone([date_created],10).

In this way, we will use it:

DateTimeZone.ToLocal(DateTime.AddZone([date_created_UTC],0))

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...