You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Amazon Redshift中获取当前会话时区?设置时区后如何查看当前会话时区?

Hey there! Great question—you’re already close to what you need. Let’s break down how to check your current Redshift session timezone and get that query working exactly as you want:

Checking Current Session Timezone in Redshift

There are a few straightforward ways to retrieve your active session timezone, and you can absolutely integrate this into the query structure you outlined:

1. Quick check with the SHOW command

The simplest way to get your current session timezone is to run this command directly:

SHOW TIMEZONE;

It’ll return a single value (like 'UTC' or 'CET') that reflects your session’s current timezone setting.

2. Use the CURRENT_TIMEZONE() function

You mentioned not finding this function, but it does exist in Redshift—just make sure to include the parentheses! You can use it in a SELECT statement like so:

SELECT CURRENT_TIMEZONE();

This outputs the same timezone string as the SHOW command.

3. Build your desired query

You can modify your sample query to include either CURRENT_TIMEZONE() or its alias SESSIONTIMEZONE to get the exact output format you’re expecting:

SELECT 
  CURRENT_TIMEZONE() AS session_timezone,
  SYSDATE,
  SYSDATE::timestamptz,
  SYSDATE::timestamptz AT TIME ZONE 'UTC',
  SYSDATE::timestamptz AT TIME ZONE 'CET';

Or using the alias:

SELECT 
  SESSIONTIMEZONE() AS session_timezone,
  SYSDATE,
  SYSDATE::timestamptz,
  SYSDATE::timestamptz AT TIME ZONE 'UTC',
  SYSDATE::timestamptz AT TIME ZONE 'CET';

After setting your timezone with SET TIMEZONE TO 'CET';, this query will return results matching the format you described, with the first column showing 'CET' as your session timezone.

Just a quick note: SESSIONTIMEZONE is an alias for CURRENT_TIMEZONE() in Redshift, so both work interchangeably.

内容的提问来源于stack exchange,提问作者RubenLaguna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 11:37:44