Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular

SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code. You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.

Copy Format Clear
CREATE TABLE tracking ( id INT PRIMARY KEY, valid_range TSTZRANGE NOT NULL, EXCLUDE USING gist (valid_range WITH &&) ); INSERT INTO tracking (id, valid_range) VALUES (1, '["2017-03-01 13:00", "2017-03-31 14:00")'), (2, '["2017-03-31 14:00", "2017-04-01 00:00")'), (3, '["2017-04-01 00:00",)'); select to_timestamp('2017-04-01','YYY-MM-DD')::TIMESTAMP WITH TIME ZONE; SELECT * FROM tracking WHERE lower(valid_range) < '2017-04-01' AND upper(valid_range) >= '2017-04-01'; SELECT * FROM tracking WHERE to_timestamp('2017-04-01','YYY-MM-DD')::TIMESTAMP WITH TIME ZONE <@ valid_range;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear