Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to insert a date series in postgreSQL

I want to insert a Date series into an existing table (public.test) in the column(day) starting from 2015-04-01 ,2015-04-02 ,.....to 2015-04-30.i know there is a generate series method in postgreSQL.But Can I generate dates using that or is there any other method to generate Dates?Any help is appreciated.

like image 351
John Avatar asked Oct 18 '25 09:10

John


1 Answers

smth like

insert into public.test ("day") 
select generate_series('2015-04-01'::date,'2015-04-30'::date,'1 day'::interval);

should work

like image 69
Vao Tsun Avatar answered Oct 20 '25 00:10

Vao Tsun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!