From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Extract between year *and* month |
Date: | 2006-11-21 06:05:53 |
Message-ID: | 20061121060553.GA24314@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
am Thu, dem 16.11.2006, um 13:03:20 -0800 mailte One folgendes:
> Hi - I'd like to return search results based on a date range that is
> selected by the user :
>
> <select name="date1yy">
> <option value="1995-01-01" selected>1995</option>
>
> <select name="date2yy">
> <option value="2006-12-31" selected>2006</option>
>
> My SQL is :
>
> select *
> from tablename
> where title like ('%nith%')
> and recall_date between
> extract(year from date '1995-01-01')
> and extract(year from date '2006-12-31')
> order by recall_date
>
> How can I add the MONTH to be included in the between statement ?
> If I select 1995 - 2006 it currently only returns rows up to 2005-12-31
and to_char(recall_date, 'yyyy-mm') between
to_char('1995-01-01'::date, 'yyyy-mm')
and to_char('2006-12-31'::date, 'yyyy-mm')
order by recall_date;
**untested**
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-11-21 06:08:07 | Re: set the default schema |
Previous Message | Frank Millman | 2006-11-21 05:49:08 | Re: pg_get_serial_sequence is inconsistent |