我正在尝试创建一个将输入时间戳转换为 PDT 的 postgres 函数。这是我的代码:
CREATE OR REPLACE FUNCTION getPdtTimestamp(inTS TIMESTAMP) RETURNS TIMESTAMP AS $$
DECLARE
outTS TIMESTAMP;
BEGIN
SELECT TIMESTAMP with time zone inTS AT TIME ZONE 'PDT' INTO outTS;
RETURN outTS;
END;
$$ LANGUAGE plpgsql;
我在这里得到的错误是:
syntax error at or near "inTS"
我的目标是创建一个如下所示的查询函数:
SELECT TIMESTAMP with time zone '2012-01-01 12:00:00' AT TIME ZONE 'PDT';
// returns a value
提前致谢