你正在运行到这里的问题是,小时提取物的结果(见下文B1)返回一个整数,再减去从REQUEST_TIME被减去给人一种结果是天数你没有想到或想要(见下面的C2)。
我相信,你所要找的东西需要将B1值转换为几小时(见下面的D1)。
选择REQUEST_TIME, TIMEZONE(CURRENT_TIMESTAMP, '美国/纽约', 'ETC/GMT') -
current_timestamp A1,
extract(hours from TIMEZONE(current_timestamp, 'America/New_York','Etc/GMT') - current_timestamp) B1,
request_time - extract(hours from TIMEZONE(current_timestamp, 'America/New_York','Etc/GMT') - current_timestamp) C1,
request_time - cast(extract(hours from TIMEZONE(current_timestamp, 'America/New_York','Etc/GMT') - current_timestamp) || ' hours ' as interval) D1
from table1;
TESTDB.ADMIN(ADMIN)-> from table1;
REQUEST_TIME | A1 | B1 | C1 | D1
---------------------+----------+----+------------+---------------------
2016-01-31 12:00:00 | 04:00:00 | 4 | 2016-01-27 | 2016-01-31 08:00:00
(1 row)
你提到你的问题,并在你的示例代码使用子查询,我但我没有”在这种情况下,不需要再次选择。
欢迎来到Stack Overflow! 。请编辑您的文章并进行格式化以提高可读性。 – gmuraleekrishna