2014-09-23 93 views
0

我想運行一個查詢像生成日期範圍天行

select ... as days where `date` is between '2010-01-28' and '2010-02-03' 

而像返回數據:

days 
--- 
28 
29 
30 
31 
1 
2 
3 
+0

對不起,其實PostgreSQL的報告 – morne 2014-09-23 10:55:49

回答

2
select extract(day from d) as days 
from generate_series(timestamp '2010-01-28', timestamp '2010-02-03', interval '1' day) as d 
order by d; 

SQLFiddle例如:http://sqlfiddle.com/#!15/d41d8/3464