Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server CURRENT_TIMEZONE Function Explained

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server does not have a CURRENT_TIMEZONE function that returns the time zone name or offset. What it does have is CURRENT_TIMEZONE(), which returns the name of the time zone configured on the server instance, not the current time or a converted timestamp. If you need the current date and time in a specific time zone, you use SYSDATETIMEOFFSET() together with AT TIME ZONE. This guide shows exactly what each function returns, how to use them, and the mistakes that trip people up.

What You'll Need

  • Access to a SQL Server instance (any edition from SQL Server 2016 onward supports AT TIME ZONE; CURRENT_TIMEZONE() was added in SQL Server 2016).
  • A query tool such as SQL Server Management Studio (SSMS), Azure Data Studio, or sqlcmd.
  • Permission to run SELECT statements. No special role is required for these built-in functions.

Step-by-Step

  1. Confirm your SQL Server version. Run SELECT @@VERSION;. If the result starts with SQL Server 2016 or later, both CURRENT_TIMEZONE() and AT TIME ZONE are available. On older versions, CURRENT_TIMEZONE() does not exist and you will get an error.
  2. See the server's configured time zone name. Run SELECT CURRENT_TIMEZONE() AS ServerTimeZone;. On a typical Windows server this returns a value such as (UTC+00:00) Dublin, Edinburgh, Lisbon, London or (UTC-08:00) Pacific Time (US & Canada). The exact string depends on the operating system's time zone setting, not on a SQL Server setting you can change inside T-SQL.
  3. Get the current date and time with offset. Run SELECT SYSDATETIMEOFFSET() AS NowWithOffset;. This returns a datetimeoffset value such as 2025-03-14 09:41:22.1234567 +00:00. This is the reliable starting point for any time zone conversion.
  4. Convert that value to a target time zone. Use AT TIME ZONE with a Windows time zone name. For example: SELECT SYSDATETIMEOFFSET() AT TIME ZONE 'Pacific Standard Time' AS PacificNow;. The result is a datetimeoffset shifted to that zone, including the correct daylight saving adjustment for the date.
  5. Convert a stored UTC column. If a column is stored as UTC (for example CreatedUtc datetime2), write SELECT CreatedUtc AT TIME ZONE 'UTC' AT TIME ZONE 'Eastern Standard Time' AS CreatedEastern FROM dbo.Orders;. The first AT TIME ZONE 'UTC' tags the value as UTC; the second converts it. Skipping the first step is the most common cause of wrong results.
  6. List valid time zone names if you are unsure. Run SELECT name FROM sys.time_zone_info ORDER BY name;. This system view returns every Windows time zone name SQL Server accepts. Copy the name exactly, including spaces and capitalization.
  7. Check the offset for a specific zone. Run SELECT name, current_utc_offset, is_currently_dst FROM sys.time_zone_info WHERE name = 'Central Standard Time';. This shows the offset in effect right now and whether daylight saving is active.
  8. Use it in a query with a filter. For reporting, convert and filter in the same expression, for example WHERE CreatedUtc AT TIME ZONE 'UTC' AT TIME ZONE 'Central Standard Time' >= '2025-01-01';. Be aware that applying a function to a column can prevent index use; if performance matters, filter on the UTC column and convert only in the SELECT list.

Common Mistakes

  • Expecting CURRENT_TIMEZONE() to return a time. It returns a time zone name string, not a timestamp. Use SYSDATETIMEOFFSET() for the current moment.
  • Using IANA names like Europe/London. SQL Server's AT TIME ZONE expects Windows time zone names such as GMT Standard Time. IANA names will raise an error.
  • Forgetting the first AT TIME ZONE 'UTC'. A plain datetime2 has no offset information. Without tagging it as UTC first, SQL Server assumes the server's local zone and your conversion will be off by the server's offset.
  • Assuming the server time zone is UTC. Many cloud instances are UTC, but on-premises servers often are not. Always check with CURRENT_TIMEZONE() or SYSDATETIMEOFFSET() before assuming.
  • Storing local times instead of UTC. Store UTC and convert at read time. Storing local times makes daylight saving transitions ambiguous and can duplicate or skip an hour.
  • Typing the zone name from memory. A single wrong character causes an error. Query sys.time_zone_info and copy the exact name.

Tips

  • Use SYSDATETIMEOFFSET() rather than GETDATE() when you need to know the offset; GETDATE() returns a plain datetime with no zone information.
  • Keep a small lookup table of the Windows zone names your application uses, so developers do not have to remember strings like Romance Standard Time.
  • For cross-database or cross-platform work, remember that AT TIME ZONE handles daylight saving for the date you supply, not for today's date. That is what makes it safer than manually adding a fixed offset.
  • When displaying times to users, convert on the server or in the application consistently. Mixing the two is a common source of off-by-one-hour bugs.
  • Test conversions around daylight saving changeover dates in both directions to confirm your queries behave as expected.

Troubleshooting

If CURRENT_TIMEZONE() returns an error saying the function is not recognized, your instance is older than SQL Server 2016. Check @@VERSION and use SYSDATETIMEOFFSET() plus manual offset handling instead, or upgrade.

If AT TIME ZONE throws an error about an invalid time zone, the name is wrong. Run SELECT name FROM sys.time_zone_info; and copy the exact string. Names are case-insensitive in most cases but spacing and punctuation must match.

If converted times are off by a fixed number of hours, you probably skipped the AT TIME ZONE 'UTC' step on a datetime2 column, or the source data is not actually UTC. Verify a few rows against a known timestamp.

If results differ between servers, compare CURRENT_TIMEZONE() and SYSDATETIMEOFFSET() on each. The server's operating system time zone setting drives the local offset, so two servers can behave differently even with identical databases.

If a query becomes slow after adding a conversion in the WHERE clause, move the conversion to the SELECT list and filter on the original UTC column, or use a computed column with an index.

Frequently Asked Questions

Does SQL Server have a CURRENT_TIMEZONE function that returns the time?

No. CURRENT_TIMEZONE() returns the name of the server's configured time zone as a string. For the current date and time with offset, use SYSDATETIMEOFFSET().

What is the difference between CURRENT_TIMEZONE and AT TIME ZONE?

CURRENT_TIMEZONE() tells you which zone the server is set to. AT TIME ZONE converts a date/time value from one zone to another and adjusts for daylight saving.

Can I use IANA time zone names like America/New_York?

No. SQL Server's AT TIME ZONE accepts Windows time zone names only, such as Eastern Standard Time. Use sys.time_zone_info to find valid names.

Why does my conversion give the wrong hour?

The most common cause is converting a datetime2 value without first tagging it as UTC using AT TIME ZONE 'UTC'. Without that tag, SQL Server treats the value as local time.

Does AT TIME ZONE handle daylight saving time?

Yes. It applies the offset that is correct for the specific date you pass in, including daylight saving changes, based on the Windows time zone rules on the server.

Can I change the server's time zone from T-SQL?

No. The time zone comes from the operating system. Change it in Windows or the host environment, then restart SQL Server if needed so the new setting is picked up.