From: Osvaldo Kussama <osvaldo_kussama@yahoo.com.br>
To: Campbell, Lance <lance@uiuc.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: subtract a day from the NOW function
Date: Thu, 7 Jun 2007 18:41:21 -0300 (ART)
Message-ID: <276697.3120.qm@web60816.mail.yahoo.com> (raw)
In-Reply-To: <A3AC4FA47DC0B1458C3E5396E685E63302395E24@SAB-DC1.sab.uiuc.edu>
--- "Campbell, Lance" <lance@uiuc.edu> escreveu:
> Table
>
> Field "some_timestamp" is a timestamp.
>
>
>
> In a "WHERE" statement I need to compare a timestamp
> field in a table
> "some_timestamp" to now() - one day.
>
>
>
> Example:
>
>
>
> SELECT some_timestamp WHERE to_char(some_timestamp,
> 'YYYYMMDD') >
> (to_char(now(), 'YYYYMMDD') - 1 day);
>
>
>
> The statement "to_char(now(), 'YYYYMMDD') - 1 day)"
> is obviously
> incorrect. I just need to know how to form this in
> a way that will
> work.
>
>
>
> If there is an entirely different solution I am all
> for it. Do note
> that I started down this path because I want to
> exclude the hour,
> minutes and seconds found in the field
> "some_timestamp" and in the
> function now().
>
Try:
SELECT some_timestamp
WHERE some_timestamp > 'yesterday'::timestamp;
Look 8.5.1.5. Special Values at:
http://www.postgresql.org/docs/8.2/interactive/datatype-datetime.html
[]s
Osvaldo
____________________________________________________________________________________
Novo Yahoo! CadĂȘ? - Experimente uma nova busca.
http://yahoo.com.br/oqueeuganhocomisso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: osvaldo_kussama@yahoo.com.br, lance@uiuc.edu
Subject: Re: subtract a day from the NOW function
In-Reply-To: <276697.3120.qm@web60816.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox