'Power BI Report builder vba "Select Case"

I currently have a code that changes date to local time by adding 3h to current time.

=Format(DateAdd("h",3,Now()), "dd.MM.yyyy hh:mm:ss tt") & " EET"

This works fine now, but the problem is that i need to have daylight savings time also taken into consideration. This means that i need to have a "Select Case" -statement, where i would evaluate:

if the date is between 27.3.2022 and 27.9.2022 +3
if the date is between 28.9.2022 and 26.3.2023 +2
if the date is between 27.3.2023 and 27.9.2023 +3
if the date is between 28.9.2023 and 26.3.2024 +2

and so on....

How do i write this in vb script (used in Power BI report builder)?

Thanks for the help!



Solution 1:[1]

The expression language for paginated reports is VB.NET, so you can use the .NET docs to find the right expression to convert the current UTC time to local time an a particular time zone, eg:

= TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"))

Solution 2:[2]

The problem with this solution is, that when I publish this to PowerBI Service, it uses the Power BI Service's default timezone, which can't be changed. Therefore the solution would need to be a static set of date-ranges which define the correct time zone despite having changes in the time due to daylight savings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Browne - Microsoft
Solution 2 Carlsberg789