how to insert a date series in postgreSQL

喜夏-厌秋 提交于 2019-12-14 02:10:43

问题


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.


回答1:


smth like

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

should work



来源:https://stackoverflow.com/questions/41220822/how-to-insert-a-date-series-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!