Using a variable period in an interval in Postgres Using a variable period in an interval in Postgres postgresql postgresql