Press "Enter" to skip to content

Category: Dates and Numbers

Clock Changes and SQL Server

Dualcore DBA turns back time:

In this post we’ll look at the behaviour of a SQL Server application that needs to deal with events that are logged over the period of a UK clock change where the clocks change from GMT (Greenwich Mean Time) to BST (British Summer Time).

The data itself is in UTC (which is good), but getting from UTC to the user’s local time can be a major challenge, especially in T-SQL. There are application libraries that make this a lot easier, which is why I recommend bouncing this up to the application layer whenever possible.

Leave a Comment

What’s the Time Again?

Umachandar Jayachandran checks a watch:

Affected locations in British Columbia, Alberta, and Manitoba will not turn their clocks back at 02:00 local time on November 1, 2026. They will remain at UTC−07:00, UTC−06:00, and UTC−05:00, respectively. 

Microsoft’s interim guidance for British Columbia, Alberta, and Manitoba describes the new Windows time zones and temporary workarounds. 

SQL Server on Windows requires the applicable Windows update—not a separate SQL Server product update. For SQL Server on Linux, Azure SQL Database, and Azure SQL Managed Instance, the following guidance applies when the new regional time zones are not yet available in your deployment. 

Click through if you have anything in that latter bucket.

Leave a Comment

Time Zones and Offsets in SQL Server

Erik Darling doesn’t know what time it is:

Or maybe you just started a new job where they cared about time zones and then your other jobs didn’t. So any, all kinds of crazy things can happen. But when you’re working with time zones, especially if you have dates that are not time zone oriented in any way, like for example, this one, this is just a date time too.

And getting used to the functions and how they work and behave can be a little tricky at first. It can be a little mind numbing. So if we run this query, what I want to show you is just we start off with a date time too that has no time zone affiliated with it.

In November, Erik will be right about Eastern time being UTC-5, as that’s Eastern Standard Time. Or maybe Erik is secretly in Indiana, in one of the counties that stays on Eastern Standard Time year-round. Hopefully I didn’t secretly dox him here.

Leave a Comment

Approximate Distinct counts in DAX

Chris Webb deals with management:

As you’ve probably seen in the blog post for the September 2026 release of Power BI, Import mode and Direct Lake mode semantic models now support the ApproximateDistinctCount() DAX function. I tested its performance on a Direct Lake semantic model with a 1.4 billion row fact table based on the NYC Taxi sample data and as you would expect, it was a lot faster than doing a regular distinct count in most cases.

Chris notes that the primary challenge is human: getting people to understand that, for their purposes and at the scale in which approximate distinct counts makes sense, non-biased approximations are just as good as actuals. That’s because 119,374,399 and 118,998,706 generally aren’t distinguishable in practice for things like monthly unique user counts. In both cases, the actual business user would still write “120 million” (or maybe “119 million” to be more precise).

Now, in cases in which the precise number does matter? Absolutely use the real distinct count. But those scenarios are rarer than you’d think.

Leave a Comment

The Pain of Time Zones

Erik Darling makes an admission:

Erik Darling here with Darling Data, and in this video, we’re going to talk about mostly AT TIME ZONE performance, but also some other interesting stuff about AT TIME ZONE. I’m going to be real honest with you, I hate timezone stuff. I hate all of it. I’ve never taken naturally to it. It’s all too weird, and managing it is just such a nightmare. 

I agree with Erik’s point about storing everything in UTC. Click through to learn how you can slow things down considerably using AT TIME ZONE in certain ways.

Comments closed

A Tale of Time

Chad Callihan gives us a rundown:

I’ve written about a few outages and issues in the past and wanted to write about a different one for this post. One that came to mind was from awhile ago when a code deployment appeared to be successful on the surface, but in reality turned into a time consuming mess.

Click through for the story. This is why I strongly recommend always storing dates and times in UTC format in SQL Server, so using GETUTCDATE() and its brethren versus GETDATE() and co. You can always translate from UTC into the relevant time zone, you don’t have to worry about daylight savings time fouling things up twice a year, and you always have a known starting point, regardless of where your server is located. This ties in with DR scenarios: if your main server is on the US east coast and your DR site is on the US west coast and both are using GETDATE() to store times, you’ll see problems after a failover.

Comments closed

Starting an Expired SQL Server VM

Rob Douglas ran out the clock:

My preview trial of 2025 was evaluation version, and if you let that run past 180 days your SQL instance just will not start. I had an old Azure VM that I fired up to grab some code from a SQL Agent job I had been playing with and hit exactly this problem. Here’s the workaround:

Click through for the process. Fortunately, Rob doesn’t stop at how to get the instance up again, but continues into installing a non-evaluation version.

Comments closed

DAX DATEADD Parameters and Calendar-Based Time Intelligence

Marco Russo and Alberto Ferrari check how two sets of functionality overlap:

The primary reason to adopt the new calendar-based time intelligence in Power BI is its flexibility. Classic time intelligence functions work out of the box and deliver meaningful results in most scenarios. However, to do so, they make assumptions about the calendar structure and the desired outcomes. Sometimes, the choices are not aligned with the user requirements, and developers need to author their own time intelligence calculations.

The new calendar-based time intelligence functions provide greater flexibility by allowing developers to configure parameters that drive the internal algorithms to meet diverse requirements. Using these parameters requires a precise understanding of the scenario for which they were built, which requires some attention to detail.

Click through to learn more.

Comments closed

TO_CHAR() in Oracle vs Postgres

Deepak Mahto diagnoses a tricky difference in behavior:

You migrate a perfectly stable Oracle application to PostgreSQL.

  • The SQL runs
  • The tests pass
  • The syntax looks correct
  • Nothing crashes

And yet… the numbers or query calculations are wrong.

Not obviously wrong. Not broken. Just different.
Those are the worst bugs the ones that quietly ship to production. This is a story about one such bug, hiding behind familiar operators, clean-looking conversions, and false confidence.

Read on for the story.

Comments closed