Re: To get a Table or View like a Calendar with dates
| От | Andreas Kretschmer |
|---|---|
| Тема | Re: To get a Table or View like a Calendar with dates |
| Дата | |
| Msg-id | 20120811170455.GA5906@tux обсуждение исходный текст |
| Ответ на | Re: To get a Table or View like a Calendar with dates (Csanyi Pal <csanyipal@gmail.com>) |
| Список | pgsql-novice |
Csanyi Pal <csanyipal@gmail.com> wrote:
> OK, I have an initial question.
>
> The start date and the end date of the first half part of school year
> are in two different tables in my database.
>
> How can I get rows in a view between those two dates?
Okay, you have the start- and end-date in 2 different tables? No
problem:
test=*# select * from t_start ;
d
------------
2012-01-01
(1 row)
Time: 0,196 ms
test=*# select * from t_end;
d
------------
2012-01-10
(1 row)
Time: 0,240 ms
test=*# select (d + s * '1day'::interval)::date from t_start,
generate_series(0, ((select d from t_end) - (select d from t_start)))s;
date
------------
2012-01-01
2012-01-02
2012-01-03
2012-01-04
2012-01-05
2012-01-06
2012-01-07
2012-01-08
2012-01-09
2012-01-10
(10 rows)
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
В списке pgsql-novice по дате отправления: