Example 1
Convert a UTC event timestamp to UTC+5:30 (India Standard Time)
Both events are stored in UTC. Adding 5 hours 30 minutes (IST offset) shifts 14:00 UTC to 19:30 IST and 18:30 UTC to midnight (00:00 the next day). PostgreSQL applies AT TIME ZONE 'UTC' first to declare the stored value as UTC, then AT TIME ZONE 'Asia/Kolkata' to convert. SQL Server requires the Windows time zone name 'India Standard Time' rather than an IANA name.
CREATE TABLE events (id INT, name VARCHAR(50), created_at DATETIME);
INSERT INTO
events
VALUES
(1, 'Launch', '2026-03-15 14:00:00'),
(2, 'Review', '2026-03-15 18:30:00');SELECT
id,
name,
created_at AS utc_time,
CONVERT_TZ (created_at, '+00:00', '+05:30') AS ist_time
FROM
events
ORDER BY
id;| id | name | utc_time | ist_time |
|---|---|---|---|
| 1 | Launch | 2026-03-15 14:00:00 | 2026-03-15 19:30:00 |
| 2 | Review | 2026-03-15 18:30:00 | 2026-03-16 00:00:00 |
CREATE TABLE events (id INT, name VARCHAR(50), created_at DATETIME);
INSERT INTO
events
VALUES
(1, 'Launch', '2026-03-15 14:00:00'),
(2, 'Review', '2026-03-15 18:30:00');SELECT
id,
name,
created_at AS utc_time,
CAST(
created_at AT TIME ZONE 'UTC' AT TIME ZONE 'India Standard Time' AS DATETIME
) AS ist_time
FROM
events
ORDER BY
id;| id | name | utc_time | ist_time |
|---|---|---|---|
| 1 | Launch | 2026-03-15T14:00:00.000 | 2026-03-15T19:30:00.000 |
| 2 | Review | 2026-03-15T18:30:00.000 | 2026-03-16T00:00:00.000 |
CREATE TABLE events (id INT, name VARCHAR(50), created_at TIMESTAMP);
INSERT INTO
events
VALUES
(1, 'Launch', '2026-03-15 14:00:00'),
(2, 'Review', '2026-03-15 18:30:00');SELECT
id,
name,
created_at AS utc_time,
(
created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Asia/Kolkata'
) AS ist_time
FROM
events
ORDER BY
id;| id | name | utc_time | ist_time |
|---|---|---|---|
| 1 | Launch | 2026-03-15T14:00:00.000Z | 2026-03-15T19:30:00.000Z |
| 2 | Review | 2026-03-15T18:30:00.000Z | 2026-03-16T00:00:00.000Z |
MySQL/MariaDB use CONVERT_TZ with offset strings. SQL Server uses AT TIME ZONE with Windows zone names. PostgreSQL uses AT TIME ZONE with IANA zone names. Timestamp formatting varies by driver.