From: Bryan \(Mailing Lists\) <bryan_lists@netmeme.org>
To: Bryan \(Mailing Lists\) <bryan_lists@netmeme.org>
To: pgsql-general@postgresql.org
Subject: Re: Date arithmatic question
Date: Fri, 17 Nov 2000 15:40:22 -0700
Message-ID: <02d001c050e7$5ecacb70$54ed90cc@netmeme.org> (raw)
References: <Pine.LNX.4.21.0011171028060.20568-100000@urd.street-light.com>
<02ba01c050e6$72f876c0$54ed90cc@netmeme.org>
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@netmeme.org>
To: <pgsql-general@postgresql.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
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: bryan_lists@netmeme.org, pgsql-general@postgresql.org
Subject: Re: Date arithmatic question
In-Reply-To: <02d001c050e7$5ecacb70$54ed90cc@netmeme.org>
References: <Pine.LNX.4.21.0011171028060.20568-100000@urd.street-light.com> <02ba01c050e6$72f876c0$54ed90cc@netmeme.org> <02d001c050e7$5ecacb70$54ed90cc@netmeme.org>
* 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