Bob Yoplait
Bob Yoplait

Reputation: 2501

Using Postgres, I want a timestamp in a specific format in a string in the query

Here is the query I would like

SELECT * FROM information_schema.tables WHERE table_name = 'shop_ean_2016_06_12';

but "2016_06_12" in the query should be yesterday. I know "NOW() - '1 day'::INTERVAL" but I want to use it in the table name comparison.

Thank you for any way of doing this.

Upvotes: 2

Views: 48

Answers (1)

d1ll1nger
d1ll1nger

Reputation: 1701

select * from information_schema.tables where table_name ='shop_ean_' || to_char(now() - interval '1 day','YYYY_MM_DD');

Upvotes: 1

Related Questions