Use desktop for interactive SQL sandbox

How to generate time series data in Postgres

Simple series

SELECT * FROM generate_series(1,3);

Date series

SELECT * from generate_series('2024-10-13 00:00:00'::timestamp, 
    '2024-10-13 23:00:00'::timestamp, '1 hour'::interval);

SQL Output

data-generation-postgres
Public
data-generation-postgres
jrz1977
PostgreSQL
Created Oct 13, 2024
Updated Oct 17, 2024
1Notes Notes
2SQL SQL
1 SQL 1 Notes
Switch to a SQL tab and press Alt+Enter to run queries
data-generation-postgres Updated 10/17/24, 1:56 AM
Notes SQL
Alt+Enter to run