Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取一个月内不包括周末的所有天数postgresql_Sql_Postgresql_Datetime_Recursive Query_Date Arithmetic - Fatal编程技术网

获取一个月内不包括周末的所有天数postgresql

获取一个月内不包括周末的所有天数postgresql,sql,postgresql,datetime,recursive-query,date-arithmetic,Sql,Postgresql,Datetime,Recursive Query,Date Arithmetic,我想为postgresql编写一个查询sql,它基本上可以返回我一个月中的所有日子,不包括周末 例如(2019年11月) 第一周:11/1 第二周:11/4->11/8 第三周:11/11->11/15 第四周:11/18->11/22 第五周:11/25->11/29 我找不到任何有帮助的postgresql请求,这应该是自动的,而不是每次手动输入新日期。一种方法是: select dt from generate_series(date'2019-11-01', date'2019-11-

我想为postgresql编写一个查询sql,它基本上可以返回我一个月中的所有日子,不包括周末

例如(2019年11月)

第一周:11/1

第二周:11/4->11/8

第三周:11/11->11/15

第四周:11/18->11/22

第五周:11/25->11/29

我找不到任何有帮助的postgresql请求,这应该是自动的,而不是每次手动输入新日期。

一种方法是:

select dt 
from generate_series(date'2019-11-01', date'2019-11-30', interval '1' day) as t(dt)
where extract(dow from dt) between 1 and 5
generate_series()
生成一个月内所有天数的列表,然后
where
子句只筛选周天数