| From: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Query on DATETIME for a date (the whole day) |
| Date: | 2011-11-04 09:14:23 |
| Message-ID: | 4EB3ACEF.8080400@archidevsys.co.nz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On 04/11/11 15:02, Tim Landscheidt wrote:
> Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>>> For a "timestamp with time zone" column, how do I find all rows where the value is within the beginning and ending of a 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
>
>
Hmm...
Most people don't realize that midnight is 12am, or 00:00:00, the very
first moment in the day! :-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tair Sabirgaliev | 2011-11-04 10:49:02 | Re: WARNING: pgstat wait timeout |
| Previous Message | Tim Landscheidt | 2011-11-04 02:02:05 | Re: Query on DATETIME for a date (the whole day) |