Re: Query on DATETIME for a date (the whole day) - Mailing list pgsql-novice

From Tim Landscheidt
Subject Re: Query on DATETIME for a date (the whole day)
Date
Msg-id m34nyk1w82.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to Query on DATETIME for a date (the whole day)  (Basil Bourque <basil.list@me.com>)
Responses Re: Query on DATETIME for a date (the whole day)  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
List pgsql-novice
Tom Lane <tgl@sss.pgh.pa.us> wrote:

>> For a "timestamp with time zone" column, how do I find all rows where the value is within the beginning and ending
ofa single date? 

> If you compare a date to a timestamp, the date is taken to mean midnight
> of its day.  So you need something along the line of

>     WHERE timestampcol BETWEEN dateval AND dateval+1

To be exact:

|       WHERE timestampcol >= dateval AND timestampcol < dateval+1

because otherwise the start of the next day is included in
the previous and therefore potentially counted twice.

Tim

pgsql-novice by date:

Previous
From: Tim Landscheidt
Date:
Subject: Re: Foreign key constraint violation when using table inheritance
Next
From: Gavin Flower
Date:
Subject: Re: Query on DATETIME for a date (the whole day)