From: | Ian Lawrence Barwick <barwick(at)gmail(dot)com> |
---|---|
To: | Csanyi Pal <csanyipal(at)gmail(dot)com> |
Cc: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to use daterange type? |
Date: | 2013-03-17 05:08:32 |
Message-ID: | CAB8KJ=gZ42QBLo_qVpOhCP_=QPDWV5py-LTV4+r2=Os_Mcf39A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2013/3/17 Csanyi Pal <csanyipal(at)gmail(dot)com>:
> Hi,
>
> I'm using postgresql 9.2.
>
> I'm trying to figure out how can I use daterange type in my database
> that is supposed to be a school calendar.
>
> I did the followings at the postgresql command prompt:
>
> create database schoolcalendar;
> create table semester_1 ( schooldays daterange );
> insert into semester_1 values ( '[2012-09-01, 2012-12-24]' );
>
> So how can I use this table further eg. to get dates of the school days
> but without Saturdays and Sundays?
I don't think there's a built-in way of doing that. You could write a function
which takes the daterange as an argument and iterates between the
daterange's lower and upper bounds but skipping dates which are
Saturdays and Sundays.
Regards
Ian Barwick
From | Date | Subject | |
---|---|---|---|
Next Message | Christophe Pettus | 2013-03-17 05:24:12 | Re: How to use daterange type? |
Previous Message | Tom Lane | 2013-03-17 04:30:18 | Re: Addled index |