Forum Discussion
DateTime Options to Always Obtain Current UK Time
- 5 months ago
V-yubandi-msft Thanks for code. It didn't work but I used it as the basis for a solution that has fix the problem for me.
= let
// Use FixedUtcNow for a stable “refresh moment” during evaluation
utcNow = DateTimeZone.FixedUtcNow(),
year = Date.Year(DateTimeZone.RemoveZone(utcNow)),// UK DST rules: BST starts 01:00 UTC last Sunday in March
// BST ends 01:00 UTC last Sunday in October
lastSundayMarch = Date.StartOfWeek(#date(year, 3, 31), Day.Sunday),
lastSundayOct = Date.StartOfWeek(#date(year,10, 31), Day.Sunday),bstStartUtc = #datetimezone(year, 3, Date.Day(lastSundayMarch), 1, 0, 0, 0, 0),
bstEndUtc = #datetimezone(year,10, Date.Day(lastSundayOct), 1, 0, 0, 0, 0),isBST = utcNow >= bstStartUtc and utcNow < bstEndUtc,
offset = if isBST then 1 else 0,ukNowZoned = DateTimeZone.SwitchZone(utcNow, offset),
ukNow = DateTimeZone.RemoveZone(ukNowZoned)
in
ukNow
Hello MJG2112
Power BI Service uses UTC, not UK time. To always show UK time, use UtcNow() and adjust for DST manually or via logic
To always get correct UK time in Microsoft Power BI, use UTC and convert it to UK time with DST logic:
use this Mcode
DateTimeZone.SwitchZone(DateTimeZone.UtcNow(), 0)
OR
Handle it dynamically using logic based on date (last Sunday of March to October)
Simple practical fix most people use
DateTimeZone.UtcNow() + #duration(0,1,0,0)
If my response helped you, please consider clicking
Accept as Solution ✅ and giving it a Like 👍 – it helps others in the community too.
Thanks,
Connect with me on:
LinkedIn |
Data With Pankaj - YouTube