| From: | rob stone <floriparob(at)gmail(dot)com> |
|---|---|
| To: | Bjørn T Johansen <btj(at)havleik(dot)no>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Strange? BETWEEN behaviour. |
| Date: | 2016-10-20 12:31:50 |
| Message-ID: | 1476966710.4374.1.camel@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, 2016-10-20 at 13:51 +0200, Bjørn T Johansen wrote:
> I have the following SQL:
>
> SELECT * from table WHERE date BETWEEN to_timestamp('20.10.2016
> 00:00:00','DD.MM.YYYY HH24:MI:SS') AND to_timestamp('20.10.2016
> 23:59:59','DD.MM.YYYY
> HH24:MI:SS')
>
> date is of type timestamp.
>
> I was expecting to get all the records that had datepart = 20.10.2016
> but I am not getting that..
>
> What am I missing?
>
>
> Regards,
>
> BTJ
>
>
I assume that you can use full stops as date separators.
Anyway, this will work:-
SELECT * from table WHERE TO_CHAR(date,'YYYYMMDD') = '20161020';
HTH,
Rob
| From | Date | Subject | |
|---|---|---|---|
| Next Message | vinny | 2016-10-20 12:37:40 | Re: Strange? BETWEEN behaviour. |
| Previous Message | Bjørn T Johansen | 2016-10-20 12:27:08 | Re: Strange? BETWEEN behaviour. |