假设您有一个类似cron的表达式
2:30 every monday and wednesday和一个句号2020.05.23 - 2021.02.02
我想为周期内的每个匹配时间创建一行
2:30 2020.05.25 (mon)
2:30 2020.05.27 (wed)如何批量创建?
(我在postgresql上,django,如果重要的话)
发布于 2020-05-23 11:13:26
要只获取所需的时间戳,可以使用以下查询
select d from
generate_series('2020.05.23 2:30:00'::timestamp, '2021.02.02 2:30:00'::timestamp, '1 day'::interval) d
where extract(dow from d) in (1,3)成批插入到表中
Insert into <table_name> (<column_name>)
select d from
generate_series('2020.05.23 2:30:00'::timestamp, '2021.02.02 2:30:00'::timestamp, '1 day'::interval) d
where extract(dow from d) in (1,3)https://stackoverflow.com/questions/61966852
复制相似问题