Re: Date arithmatic question

From: "Bryan \(Mailing Lists\)" <bryan_lists(at)netmeme(dot)org>
To: "Bryan \(Mailing Lists\)" <bryan_lists(at)netmeme(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Date arithmatic question
Date: 2000-11-17 22:40:22
Message-ID: 02d001c050e7$5ecacb70$54ed90cc@netmeme.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Whoops, I had a typo in my translation; the second query I quoted should
read as follows:

select * from t where date_part('day', age('now', s)) = ? and
date_part('month', age('now', s)) = 0

Thanks,

Bryan

----- Original Message -----
From: "Bryan (Mailing Lists)" <bryan_lists(at)netmeme(dot)org>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Friday, November 17, 2000 3:33 PM
Subject: [GENERAL] Date arithmatic question

> I have a table "t" with a timestamp column "s". I am trying to issue a
query
> to find all rows where s is exactly some number of days old (rounded off).
>
> I have tried this:
>
> select * from t where date_part('day', age('now', s)) = ?
>
> But this only looks at the day of the month; e.g. if my parameter is "5",
> then it will return all rows that are 5 days old, as well as 1 month 5
days,
> as well as 2 months 5 days, etc.
>
> I have also tried this:
>
> select * from t where date_part('day', age('now', s)) = ? and
> date_part('month', age('now', status_last_update)) = 0
>
> But this restricts my parameter to 30 days or less; greater than 30 days
and
> the query doesn't return anything.
>
> What is the correct way to express this?
>
> Thank you,
>
> Bryan
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message j.uy 2000-11-18 20:51:56 newbie: execute an sql script
Previous Message Bryan (Mailing Lists) 2000-11-17 22:33:46 Date arithmatic question

Browse pgsql-general by date

  From Date Subject
Next Message Max Fonin 2000-11-17 23:13:23 Re: is there a mysql to postgresql sql converter?
Previous Message Bryan (Mailing Lists) 2000-11-17 22:33:46 Date arithmatic question