| From: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
|---|---|
| To: | "Campbell, Lance" <lance(at)uiuc(dot)edu> |
| Cc: | Michael Glaesemann <grzm(at)seespotcode(dot)net>, pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: subtract a day from the NOW function |
| Date: | 2007-06-07 18:12:00 |
| Message-ID: | 46684A70.4080903@g2switchworks.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-sql |
Campbell, Lance wrote:
> Michael,
> So based on your feedback would it be better to do option A or B below?
>
> 1) I have a timestamp field, "some_timestamp", in table "some_table".
> 2) I want to compare field "some_timestamp" to the current date - 1 day.
> I need to ignore hours, minutes and seconds.
>
You might want to use date_trunc then:
select * from sometable where date_trunc('day',tiemstampfield) >
date_trunc('day',now() - interval '1 day');
or something like that.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | codeWarrior | 2007-06-07 18:14:14 | Re: querying the age of a row |
| Previous Message | Anton Melser | 2007-06-07 18:03:14 | Re: should the postgres user have a password? |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Glaesemann | 2007-06-07 18:22:05 | Re: subtract a day from the NOW function |
| Previous Message | Campbell, Lance | 2007-06-07 17:49:19 | Re: subtract a day from the NOW function |