Skip to content
Advertisement

Tag: timescaledb

How do I join a string and an int in PostgreSQL?

I have a procedure with an int parameter. The syntax for the add_retention_policy function is add_retention_policy(‘hypertable’, INTERVAL ‘x days’, true). I want to prefix the hypertable with the schema which is always ‘schema_’ and then followed by the id parameter, how do I do that? Answer You just need to rewrite the INTERVAL part in your function call as days

TimescaleDB – how get timestamp differences between rows?

Say you need to know how long something was ‘active’ in a time range – (with timestamp in minutes, as an example) – For a 0-15min bucket, the answer would be 6.8-3.5 + 15-9.3 = 9.0mins. (ie the first active state lasts 6.8-3.5mins, the next one goes from 9.3mins to the 15min barrier). How would you do something like this

Advertisement