Ryo Matsuzaka
Ryo Matsuzaka

Reputation: 354

How to select specific time range in AWS Timestream

In Grafana, I use AWS Timestream as data source. And I want to show only specific time range such as 9:00 to 21:00. AWS Timestream supports SQL so I write like this.

SELECT *
FROM testDB.testTable
WHERE measure_name = 'test'
AND time BETWEEN time('09:00:00') AND time('21:00:00')
ORDER BY time DESC LIMIT 10080

But I got the following error. Could you tell me what is wrong with it?

ValidationException: line 4:18: Problems with function : time. Either the function does not exist, or there is a problem with a dependent function

Upvotes: 1

Views: 1343

Answers (1)

Juanchi Rios
Juanchi Rios

Reputation: 129

SELECT *
FROM testDB.testTable
WHERE measure_name = 'test'
AND hour(time) BETWEEN 9 AND 20
ORDER BY time DESC LIMIT 10080

The above query will fetch records which hours are between '09:00:00.000000000' and '20:59:59.999999999'

Upvotes: 2

Related Questions