Is it possible to query the last few hours using a timestamp in Redshift?

I am trying to write a query to find the last 2 hours of data.

First I tried using INTERVAL:

select count(*) from data where created_at > CURRENT_TIMESTAMP - (INTERVAL '2 hours');

but I get the error:

ERROR: Not implemented
Item:
-------------------------------------------- ---
Error: Not implemented code: 1001
context: '! null_tst '- function: timestamp_gt_timestamptz (), funcID = 2523
request: 2734016
location: cg_expr.cpp: 295
process: padbmaster [pid = 25255]
-------------------- ---------------------------

Does anyone know a way to do this in Redshift without using absolute timestamps?

+4
source share
1
SELECT  count(*)
FROM    data
WHERE   created_at >= 
dateadd(day/or_other_parameter,0,CURRENT_TIMESTAMP) - '2 hr'::INTERVAL

dateadd,

0

Source: https://habr.com/ru/post/1568407/


All Articles