From: | Matthias(dot)Pitzl(at)izb(dot)de |
---|---|
To: | david(dot)hunter(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Extract between year *and* month |
Date: | 2006-11-21 08:18:23 |
Message-ID: | 11EC9A592C31034C88965C87AF18C2A70CFCF7@m0000s61 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
You could use date_trunc instead of extract to truncate the date down to the
month:
select date_trunc('month','2006-12-31'::timestamp);
date_trunc
---------------------
2006-12-01 00:00:00
Greetings,
Matthias
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of One
> Sent: Thursday, November 16, 2006 10:03 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] Extract between year *and* month
>
>
> 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
>
> THANKS!
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
From | Date | Subject | |
---|---|---|---|
Next Message | Paefgen, Peter (LDS) | 2006-11-21 09:13:41 | Re: ORDER BY |
Previous Message | Richard Huxton | 2006-11-21 07:54:16 | Re: tracking errors in psql |