Forum Discussion
Last Refresh Date change Timezone
- 4 years ago
lkshck , I think you should use
Date.From(DateTime.FixedLocalNow())
for timezone refer if this can help
I was able to use a SQL query to achieve this. For this solution, you'll need to be able to connect to a SQL server and database (any server/DB will do because you won't actually be querying a table).
From your Power BI Desktop file, click Get Data > SQL Server. Enter the Server name and Database name, then expand Advanced options. Paste the below code in the SQL statement field then click OK.
Note: This is for Pacific timezone, but you can modify this code for any timezone. To see the list of supported
timezone names use SELECT * FROM sys.time_zone_info then replace the 'Pacific Standard Time' with the name of your timezone for both the second and third columns. Consider updating the column names since these reference PT for Pacific Time. Repeat the second and third lines of code with alternate timezones should you want more timezone options. Ultimately, only the third column matters, but I left the UTC and Offset columns to demonstrate how the query works.
SELECT
CAST(GETDATE() AT TIME ZONE 'UTC' AS DATETIME) AS [LastRefreshUTC]
,CAST(LEFT(RIGHT(GETDATE() AT TIME ZONE 'UTC' AT TIME ZONE 'Pacific Standard Time',6),3) AS INT) AS [PTOffset]
,DATEADD(HOUR,CAST(LEFT(RIGHT(GETDATE() AT TIME ZONE 'UTC' AT TIME ZONE 'Pacific Standard Time',6),3) AS INT),CAST(GETDATE() AT TIME ZONE 'UTC' AS DATETIME)) AS [LastRefreshPT]